Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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-v23-03
backend
Commits
2542d0f3
Commit
2542d0f3
authored
1 year ago
by
Stian Lyng
Browse files
Options
Downloads
Patches
Plain Diff
add github workflow
parent
cd18ea3b
Branches
217-add-algotihm-to-find-relevant-statistics
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+44
-11
44 additions, 11 deletions
Dockerfile
src/.github/workflows/build.yml
+39
-0
39 additions, 0 deletions
src/.github/workflows/build.yml
with
83 additions
and
11 deletions
Dockerfile
+
44
−
11
View file @
2542d0f3
# Use a specific version of the JDK image to ensure consistency
FROM
eclipse-temurin:19-jdk-alpine
AS
build
## Use a specific version of the JDK image to ensure consistency
#FROM eclipse-temurin:19-jdk-alpine AS build
#
## Set the working directory
#WORKDIR /app
#
## Copy the pom.xml file first, and then download dependencies separately to take advantage of Docker layer caching
#COPY pom.xml .
#RUN apk add maven
#RUN mvn dependency:go-offline
#
## Copy the source code and package the application
#COPY src ./src
#RUN mvn clean package
#
## Use a new stage to reduce the final image size
#FROM eclipse-temurin:19-jre-alpine
#
## Set the working directory
#WORKDIR /app
#
## Copy the packaged application from the build stage
#COPY --from=build /app/target/SmartMat-0.0.1-SNAPSHOT.jar ./SmartMat.jar
#
## Define the entrypoint and expose the application port
#ENTRYPOINT ["java","-jar","SmartMat.jar"]
#EXPOSE 8080
#
# Use the official Maven image as the base image
FROM
maven:3.6.3-jdk-11
as
builder
# Set the working directory
WORKDIR
/app
# Copy the pom.xml file
first, and then download dependencies separately to take advantage of Docker layer caching
# Copy the pom.xml file
to the working directory
COPY
pom.xml .
RUN
apk add maven
# Download and cache dependencies to improve build times
RUN
mvn dependency:go-offline
# Copy the
source code and package
the application
# Copy the
rest of
the application
code
COPY
src ./src
# Build the application and package it as a JAR file
RUN
mvn clean package
# Use
a new stage to reduce the final image siz
e
FROM
eclipse-temurin
:1
9
-jre-
alpine
# Use
the official OpenJDK image as the runtime imag
e
FROM
openjdk
:1
1
-jre-
slim
# Set the working directory
WORKDIR
/app
# Copy the
packaged application
from the build stage
COPY
--from=build /app/target/
SmartMat-0.0.1-SNAPSHOT.jar ./SmartMat
.jar
# Copy the
JAR file
from the build
er
stage
COPY
--from=build
er
/app/target/
*.jar ./app
.jar
# Define the entrypoint and expose the application port
ENTRYPOINT
["java","-jar","SmartMat.jar"]
# Expose the port the application will run on
EXPOSE
8080
# Run the application
CMD
["java", "-jar", "app.jar"]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/.github/workflows/build.yml
0 → 100644
+
39
−
0
View file @
2542d0f3
name
:
Build
on
:
push
:
branches
:
-
main
pull_request
:
branches
:
-
main
jobs
:
build
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
Checkout
uses
:
actions/checkout@v2
-
name
:
Set up JDK
11
uses
:
actions/setup-java@v2
with
:
java-version
:
'
11'
distribution
:
'
adopt'
-
name
:
Cache Maven dependencies
uses
:
actions/cache@v2
with
:
path
:
~/.m2
key
:
${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys
:
${{ runner.os }}-m2
-
name
:
Build with Maven
run
:
mvn clean install -B
-
name
:
Upload JAR file
uses
:
actions/upload-artifact@v2
with
:
name
:
my-jar-file
path
:
target/*.jar
\ No newline at end of file
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