diff --git a/.env b/.env new file mode 100644 index 0000000..487397e --- /dev/null +++ b/.env @@ -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 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 489af39..0f1fed2 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -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 }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 179e96d..3a27005 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..607adc6 --- /dev/null +++ b/docker-compose.yml @@ -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