Skip to content

Commit 3e1cc8a

Browse files
Task/deploy railway (#10)
* add docker file for deployment * add docker file for deployment
1 parent 6d1221a commit 3e1cc8a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

deploy/docker/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Step 1: Build the application using Gradle from the root directory
2+
FROM eclipse-temurin:21.0.4_7-jdk AS build
3+
4+
WORKDIR /app
5+
6+
# Copy the Gradle wrapper and necessary files from the root
7+
COPY gradlew gradlew
8+
COPY gradle gradle
9+
COPY build.gradle settings.gradle ./
10+
COPY gradle.properties gradle.properties
11+
12+
# Copy the source code for all modules (from root)
13+
COPY .. .
14+
15+
# Grant execution permission to the Gradle wrapper
16+
RUN chmod +x gradlew
17+
18+
# Run the Gradle build from the root (including skipping tests if necessary)
19+
RUN ./gradlew clean build --no-daemon -x test
20+
21+
# Step 2: Create a minimal image with JRE and the built app
22+
FROM eclipse-temurin:21.0.4_7-jre
23+
24+
WORKDIR /opt
25+
26+
# Copy the built JAR from the build stage
27+
COPY --from=build /app/trading-app/build/libs/trading-app.jar /opt/app.jar
28+
29+
# Copy the entrypoint script
30+
COPY ./deploy/docker/entrypoint.sh /opt/entrypoint.sh
31+
32+
# Grant execution permission to the entrypoint script
33+
RUN chmod +x /opt/entrypoint.sh
34+
35+
# Expose port 8080
36+
EXPOSE 8080
37+
38+
# Set the entrypoint
39+
ENTRYPOINT ["/opt/entrypoint.sh"]

deploy/docker/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
exec java -jar /opt/app.jar

0 commit comments

Comments
 (0)