Skip to content

Commit efb0ec0

Browse files
committed
add workflow with dockerfile
1 parent 7a81bdc commit efb0ec0

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build and Deploy Docker Image
2+
3+
on: [push]
4+
5+
jobs:
6+
build-and-deploy:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Build Docker Image
11+
run: |
12+
docker build -t docker.pkg.github.com/yanni8/m295/app:latest .
13+
- name: Login to GitHub Packages
14+
run: |
15+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin
16+
- name: Push Docker Image
17+
run: |
18+
docker push docker.pkg.github.com/yanni8/m295/app:latest

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM maven:3 as builder
2+
3+
WORKDIR /app
4+
COPY . .
5+
RUN mvn -Dmaven.test.skip=true package
6+
7+
FROM openjdk:17-jdk
8+
9+
WORKDIR /home/app
10+
RUN useradd -ms /bin/bash -u 999 app
11+
USER app
12+
COPY --from=builder /app/target/*.jar runner.jar
13+
EXPOSE 8080
14+
15+
ENTRYPOINT ["java", "-jar", "runner.jar"]

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.validation.V
77
spring.jpa.show-sql=true
88
spring.jpa.generate-ddl=true
99
spring.jpa.hibernate.ddl-auto=update
10-
spring.datasource.url=jdbc:postgresql://${DB_URL:localhost}:${DB_PORT:5432}/demo
10+
spring.datasource.url=jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/demo
1111
spring.datasource.username=${DB_USERNAME:postgres}
1212
spring.datasource.password=${DB_PASSWORD:password}
1313
spring.datasource.driverClassName=org.postgresql.Driver

0 commit comments

Comments
 (0)