Skip to content

Commit

Permalink
Fix Dockerfile adding mven step to build image and remove target fold…
Browse files Browse the repository at this point in the history
…er (#68)

* Fix Dockerfile adding mven step to build image and remove target folder
  • Loading branch information
LauroSilveira authored Nov 15, 2023
1 parent 4de48da commit aafe3ba
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_PRO=mongodb+srv://laurosilveira:6Vos5cYJ9JfxidsQ@alura-flix-test.qixe2kd.mongodb.net/?retryWrites=true&w=majority
DATABASE_TEST=mongodb+srv://alura-flix-admin:UxOM6SSAtQHpDeEd@alura-flix.z61opfc.mongodb.net/?retryWrites=true&w=majority
JWT_SECRET=123456
3 changes: 2 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
run: docker build . --file Dockerfile --tag alura-flix-api:$(date +%s) --build-arg DATABASE_PRO=${{ secrets.DATABASE_PRO }} --build-arg DATABASE_TEST=${{ secrets.DATABASE_TEST }} --build-arg DATABASE_TEST=${{ secrets.DATABASE_TEST }}
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ RUN mvn clean package

FROM eclipse-temurin:21-jre-alpine
## Arguments used with github secrets
ARG JWT_SECRET
ARG DATABASE_PRO
ARG DATABASE_TEST
ARG JWT_SECRET

## work directory by default
WORKDIR /alura-flix-api
## copy all files from target and put in to work directory
COPY --from=build target/alura-flix-api-0.0.1-SNAPSHOT.jar alura-flix-api.jar
COPY --from=build target/*.jar alura-flix-api.jar
EXPOSE 8080

ENTRYPOINT ["java", "-jar", "alura-flix-api.jar"]
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.9'
services:
alura_flix_api:
image: "laurocorreia/alura-flix-api:latest"
container_name: "alura_flix_api"
networks:
- compose-brigde
ports:
- 8080:8080
environment:
DATABASE_PRO: ${DATABASE_PRO}
JWT_SECRET: ${JWT_SECRET}
networks:
compose-brigde:
driver: bridge

0 comments on commit aafe3ba

Please sign in to comment.