Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,9 @@ jobs:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}


- name: Set up Docker Buildx
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2

- name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 17

- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build

- name: Build docker image (no push)
uses: docker/build-push-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build/
.gradle/
.idea/
.vscode/

/.classpath
/.project
Expand Down
42 changes: 36 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
FROM openjdk:17-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
ARG JAR_FILE=build/libs/showcase.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
FROM eclipse-temurin:17-jdk-jammy AS base

# Use the base image to build a layer with the gradle wrapper. This means we dont need to
# download the wrapper every time we build the project as the gradle layer is cached by docker
FROM base as gradle

WORKDIR /app

COPY gradle/ gradle
COPY gradlew .
COPY settings.gradle .

RUN ./gradlew tasks

# Use the gradle layer built above as the basis to build the java project. This layer should only
# get build if the previous layer is build or the files COPYed in are changed
FROM gradle as builder

WORKDIR /app

COPY build.gradle .
COPY src/ src

RUN ./gradlew build

# Use the base image and copy in the jar file built in the layer above, meaning we get an image built
# using the project source code, but with just the packaged code in it.
FROM base AS runner

WORKDIR /app

ARG JAR_FILE=/app/build/libs/showcase.jar

COPY --from=builder ${JAR_FILE} app.jar

ENTRYPOINT ["java","-jar","app.jar"]
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.1'

services:

showcase:
build:
context: .
ports:
- 8080:8080
- 8000:8000
environment:
- JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000