Question

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

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 :)


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
May 6, 2024

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel