Giter VIP home page Giter VIP logo

javainadockercharlos16v's Introduction

Java In A Docker:

Exercise to practice the deployment of a JAR file in a Docker image.

You can find the image in DockerHub! https://hub.docker.com/repository/docker/charlos16v/romansgohome

RUN IT:

docker run -it --publish 80:5000 charlos16v/romansgohome

Dockerfile:

# First stage of the build, we use a 3.6.1 maven slim parent image.
FROM maven:3.6.1-jdk-11-slim AS mvn_build

# Copy the src and pom.
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app

# We execute mvn package to get the .jar
RUN mvn -f /usr/src/app/pom.xml clean package

# On the second stage of the build we use a openjdk11-jre slim buster image.
FROM openjdk:11-jre-slim-buster

# We indicate the maintainer information.
MAINTAINER Carlos Uriel <[email protected]>

# We specify information of the image, thats going to be in the metadata of the image.
LABEL "edu.pingpong.romansGoHome"="Kata Romans Go Home" \
        version="1.0" \
        description="Kata Romans Go Home made in Java" \
        maintainer="[email protected]"

# We indicate the por on wich the container listens for connections.
EXPOSE 5000

# We indicate the working directory.
WORKDIR $HOME/app

# We copy only the artifact we need from the first stage(mvn_build).
COPY --from=mvn_build /usr/src/app/target/romansGoHome-1.0-SNAPSHOT.jar /usr/app/romansGoHome-1.0-SNAPSHOT.jar

# Specify the user to the container.
ENV USER=appuser
RUN adduser \
    --disabled-password \
    --home "$(pwd)" \
    --no-create-home \
    "$USER"
USER appuser

# We set the image main command.
ENTRYPOINT ["java","-jar","/usr/app/romansGoHome-1.0-SNAPSHOT.jar"]

javainadockercharlos16v's People

Contributors

charlos16v avatar github-classroom[bot] avatar

Watchers

 avatar  avatar

Forkers

charlos16v

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.