Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106-2024-07
backend
Commits
85355c32
There was an error fetching the commit references. Please try again later.
Commit
85355c32
authored
1 year ago
by
Andreas
Browse files
Options
Downloads
Patches
Plain Diff
refactor/Updated Dockerfile
parent
641a196a
No related branches found
No related tags found
1 merge request
!85
Feat/workflow implement docker push and deploy
Pipeline
#283529
passed
1 year ago
Stage: build_test
Stage: docker_build_and_push
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Dockerfile
+21
-8
21 additions, 8 deletions
Dockerfile
with
21 additions
and
8 deletions
Dockerfile
+
21
−
8
View file @
85355c32
FROM
maven:3-jdk-8-alpine
as
builder
# Step 1: Build the application
FROM
maven:3.8.5-openjdk-17
AS
build
WORKDIR
/usr/src/app
# Set the working directory in the container
WORKDIR
/app
COPY
. /usr/src/app
# Copy the Maven pom.xml and source code into the container
RUN
mvn package
COPY
pom.xml .
COPY
src ./src
FROM
openjdk:8-jre-alpine
# Compile and package the application to an executable JAR
RUN
mvn clean package
-DskipTests
COPY
--from=builder /usr/src/app/target/*.jar /app.jar
# Step 2: Run the application
FROM
openjdk:17-slim
# Set the deployment directory
WORKDIR
/app
# Copy the JAR from the build stage to the run stage
COPY
--from=build /app/target/*.jar app.jar
# Expose the port the app runs on
EXPOSE
8080
EXPOSE
8080
ENTRYPOINT
["java"]
# Run the application
CMD
["-jar", "/app.jar"]
CMD
["java", "-jar", "app.jar"]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment