Skip to content

Commit 1b3dca2

Browse files
docker files
1 parent 2d3abd8 commit 1b3dca2

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed

.dockerignore

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.factorypath
12+
**/.git
13+
**/.gitignore
14+
**/.idea
15+
**/.project
16+
**/.sts4-cache
17+
**/.settings
18+
**/.toolstarget
19+
**/.vs
20+
**/.vscode
21+
**/.next
22+
**/.cache
23+
**/*.dbmdl
24+
**/*.jfm
25+
**/charts
26+
**/docker-compose*
27+
**/compose.y*ml
28+
**/Dockerfile*
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/vendor
32+
LICENSE
33+
README.md
34+
**/*.class
35+
**/*.iml
36+
**/*.ipr
37+
**/*.iws
38+
**/*.log
39+
**/.apt_generated
40+
**/.gradle
41+
**/.gradletasknamecache
42+
**/.nb-gradle
43+
**/.springBeans
44+
**/build
45+
**/dist
46+
**/gradle-app.setting
47+
**/nbbuild
48+
**/nbdist
49+
**/nbproject/private
50+
**/target
51+
*.ctxt
52+
.mtj.tmp
53+
.mvn/timing.properties
54+
buildNumber.properties
55+
dependency-reduced-pom.xml
56+
hs_err_pid*
57+
pom.xml.next
58+
pom.xml.releaseBackup
59+
pom.xml.tag
60+
pom.xml.versionsBackup
61+
release.properties
62+
replay_pid*

Dockerfile

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/go/dockerfile-reference/
6+
7+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8+
9+
################################################################################
10+
11+
# Create a stage for resolving and downloading dependencies.
12+
FROM eclipse-temurin:21-jdk-jammy as deps
13+
14+
WORKDIR /build
15+
16+
# Copy the mvnw wrapper with executable permissions.
17+
COPY --chmod=0755 mvnw mvnw
18+
COPY .mvn/ .mvn/
19+
20+
# Download dependencies as a separate step to take advantage of Docker's caching.
21+
# Leverage a cache mount to /root/.m2 so that subsequent builds don't have to
22+
# re-download packages.
23+
RUN --mount=type=bind,source=pom.xml,target=pom.xml \
24+
--mount=type=cache,target=/root/.m2 ./mvnw dependency:go-offline -DskipTests
25+
26+
################################################################################
27+
28+
# Create a stage for building the application based on the stage with downloaded dependencies.
29+
# This Dockerfile is optimized for Java applications that output an uber jar, which includes
30+
# all the dependencies needed to run your app inside a JVM. If your app doesn't output an uber
31+
# jar and instead relies on an application server like Apache Tomcat, you'll need to update this
32+
# stage with the correct filename of your package and update the base image of the "final" stage
33+
# use the relevant app server, e.g., using tomcat (https://hub.docker.com/_/tomcat/) as a base image.
34+
FROM deps as package
35+
36+
WORKDIR /build
37+
38+
COPY ./src src/
39+
RUN --mount=type=bind,source=pom.xml,target=pom.xml \
40+
--mount=type=cache,target=/root/.m2 \
41+
./mvnw package -DskipTests && \
42+
mv target/$(./mvnw help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout).jar target/app.jar
43+
44+
45+
################################################################################
46+
47+
# Create a new stage for running the application that contains the minimal
48+
# runtime dependencies for the application. This often uses a different base
49+
# image from the install or build stage where the necessary files are copied
50+
# from the install stage.
51+
#
52+
# The example below uses eclipse-turmin's JRE image as the foundation for running the app.
53+
# By specifying the "21-jre-jammy" tag, it will also use whatever happens to be the
54+
# most recent version of that tag when you build your Dockerfile.
55+
# If reproducibility is important, consider using a specific digest SHA, like
56+
# eclipse-temurin@sha256:99cede493dfd88720b610eb8077c8688d3cca50003d76d1d539b0efc8cca72b4.
57+
FROM eclipse-temurin:21-jre-jammy AS final
58+
59+
# Create a non-privileged user that the app will run under.
60+
# See https://docs.docker.com/go/dockerfile-user-best-practices/
61+
ARG UID=10001
62+
RUN adduser \
63+
--disabled-password \
64+
--gecos "" \
65+
--home "/nonexistent" \
66+
--shell "/sbin/nologin" \
67+
--no-create-home \
68+
--uid "${UID}" \
69+
appuser
70+
USER appuser
71+
72+
# Copy the executable from the "package" stage.
73+
COPY --from=package build/target/app.jar app.jar
74+
75+
EXPOSE 8080
76+
77+
ENTRYPOINT [ "java", "-jar", "app.jar" ]

README.Docker.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Building and running your application
2+
3+
When you're ready, start your application by running:
4+
`docker compose up --build`.
5+
6+
Your application will be available at http://localhost:8080.
7+
8+
### Deploying your application to the cloud
9+
10+
First, build your image, e.g.: `docker build -t myapp .`.
11+
If your cloud uses a different CPU architecture than your development
12+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
13+
you'll want to build the image for that platform, e.g.:
14+
`docker build --platform=linux/amd64 -t myapp .`.
15+
16+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
17+
18+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
19+
docs for more detail on building and pushing.

compose.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Docker Compose reference guide at
3+
# https://docs.docker.com/go/compose-spec-reference/
4+
5+
# Here the instructions define your application as a service called "server".
6+
# This service is built from the Dockerfile in the current directory.
7+
# You can add other services your application may depend on here, such as a
8+
# database or a cache. For examples, see the Awesome Compose repository:
9+
# https://github.com/docker/awesome-compose
10+
services:
11+
server:
12+
build:
13+
context: .
14+
ports:
15+
- 8080:8080
16+
17+
# The commented out section below is an example of how to define a PostgreSQL
18+
# database that your application can use. `depends_on` tells Docker Compose to
19+
# start the database before your application. The `db-data` volume persists the
20+
# database data between container restarts. The `db-password` secret is used
21+
# to set the database password. You must create `db/password.txt` and add
22+
# a password of your choosing to it before running `docker-compose up`.
23+
# depends_on:
24+
# db:
25+
# condition: service_healthy
26+
# db:
27+
# image: postgres
28+
# restart: always
29+
# user: postgres
30+
# secrets:
31+
# - db-password
32+
# volumes:
33+
# - db-data:/var/lib/postgresql/data
34+
# environment:
35+
# - POSTGRES_DB=example
36+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
37+
# expose:
38+
# - 5432
39+
# healthcheck:
40+
# test: [ "CMD", "pg_isready" ]
41+
# interval: 10s
42+
# timeout: 5s
43+
# retries: 5
44+
# volumes:
45+
# db-data:
46+
# secrets:
47+
# db-password:
48+
# file: db/password.txt
49+

0 commit comments

Comments
 (0)