Report this

What is the reason for this report?

How to connect java android app from Android Studio to App Platform?

Posted on April 27, 2024
Dani

By Dani

Hi!

I’m on the App platform, and I try to “Create resource from source code”, and I choose my repository on GitHub, but I get a “no component detected” error.

So I looked around and found this answer saying that you should add a dockerfile. (Here:https://www.digitalocean.com/community/questions/what-are-the-possible-options-for-deploying-my-java-application-to-digitalocean)

I’m doing this for the first time. I don’t know what should go on the dockerfile or where the dockerfile should go! My app is in java, and I’m writing it on Android Studio and storing the code on GitHub.

What should the dockerfile contain? Where should I place it?

Thank you so much for any help :)



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey!

Indeed, Java is not a supported buildpack out of the box with the App Platform. You can find a list of all available buildpacks here:

https://docs.digitalocean.com/products/app-platform/reference/buildpacks/

As an alternative option, you could indeed write a Dockerfile with all of the required dependencies for your project and use this instead to deploy your app.

Dockerizing a Java app might differ depending on your app requirements, but it should be more or less the same as described on the Docker website itself:

https://docs.docker.com/language/java/containerize/

The Dockerfile should be placed at the root of your backend project’s repository.

Example Dockerfile for a Java application:

# Use an official OpenJDK runtime as a parent image
FROM openjdk:17-jdk-alpine

# Set the working directory
WORKDIR /app

# Copy the jar file into the image
COPY target/my-backend-app.jar /app/my-backend-app.jar

# Expose the application's port
EXPOSE 8080

# Run the jar file
ENTRYPOINT ["java", "-jar", "/app/my-backend-app.jar"]

Hope that this helps!

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.