Skip to content

Commit 47b8988

Browse files
committed
Add dockerfile
1 parent 44c46b9 commit 47b8988

3 files changed

Lines changed: 34 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
cache: maven
2323
distribution: corretto
2424
- name: Maven Build
25-
run: ./mvnw spring-boot:build-image -DimageName=registry.digitalocean.com/davisellwoodwebsite/website:latest
25+
run: ./mvnw install --no-transfer-progress
26+
- name: tag docker image
27+
run:
28+
docker tag davisellwood/website:latest registry.digitalocean.com/davisellwood/website:latest
2629
- name: Install doctl
2730
uses: digitalocean/action-doctl@v2
2831
with:
@@ -32,4 +35,4 @@ jobs:
3235
doctl registry login
3336
- name: docker push
3437
run:
35-
docker push registry.digitalocean.com/davisellwoodwebsite/website:latest
38+
docker push registry.digitalocean.com/davisellwood/website:latest

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Use the base image that your Spring Boot app uses
2+
FROM openjdk:17-jdk-slim
3+
4+
# Copy the application JAR file into the container
5+
COPY target/website-*.jar /website.jar
6+
7+
# Install libgcc (or any other libraries you need)
8+
RUN apt-get update && apt-get install -y libgcc1
9+
10+
# Expose the port the app will run on
11+
EXPOSE 8080
12+
13+
# Run the Spring Boot app
14+
ENTRYPOINT ["java", "-jar", "/website.jar"]

pom.xml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,22 @@
279279
</configuration>
280280
</plugin>
281281
<plugin>
282-
<groupId>org.springframework.boot</groupId>
283-
<artifactId>spring-boot-maven-plugin</artifactId>
282+
<groupId>com.spotify</groupId>
283+
<artifactId>dockerfile-maven-plugin</artifactId>
284+
<version>1.4.13</version>
285+
<executions>
286+
<execution>
287+
<goals>
288+
<goal>build</goal>
289+
</goals>
290+
</execution>
291+
</executions>
284292
<configuration>
285-
<excludes>
286-
<exclude>
287-
<groupId>org.projectlombok</groupId>
288-
<artifactId>lombok</artifactId>
289-
</exclude>
290-
</excludes>
291-
<image>
292-
<name>${imageName}</name>
293-
</image>
293+
<repository>davisellwood/website</repository>
294+
<tag>latest</tag>
295+
<buildArgs>
296+
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
297+
</buildArgs>
294298
</configuration>
295299
</plugin>
296300
</plugins>

0 commit comments

Comments
 (0)