diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a98e767..207dc3ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: - uses: actions/checkout@v4 - name: Create .env file - run: echo "REACT_APP_API_ENDPOINT=${{ secrets.DEPLOY_HOST }}:8080" > webapp/.env + run: echo "REACT_APP_API_ENDPOINT=http://${{ secrets.DEPLOY_HOST }}:8080" > webapp/.env - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 @@ -89,6 +89,25 @@ jobs: workdir: webapp buildargs: | REACT_APP_API_ENDPOINT + docker-push-question-generator: + runs-on: ubuntu-latest + needs: [ e2e-tests ] + steps: + - uses: actions/checkout@v4 + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + env: + DATABASE_USER: ${{ secrets.DATABASE_USER }} + DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + with: + name: arquisoft/wiq_en2b/question-generator + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + workdir: questiongenerator + buildargs: | + DATABASE_USER + DATABASE_PASSWORD deploy: name: Deploy over SSH runs-on: ubuntu-latest @@ -113,4 +132,4 @@ jobs: echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env echo "API_URI=http://${{ secrets.DEPLOY_HOST }}:8080" >> .env docker compose --profile prod down - docker compose --profile prod up -d + docker compose --profile prod up -d --pull diff --git a/docker-compose.yml b/docker-compose.yml index 1c1abf94..2b431d97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,22 @@ services: ports: - "8080:8080" + question-generator: + container_name: question-generator-${teamname:-defaultASW} + image: ghcr.io/arquisoft/wiq_en2b/question-generator:latest + profiles: [ "dev", "prod" ] + build: + context: ./questiongenerator + args: + DATABASE_USER: ${DATABASE_USER} + DATABASE_PASSWORD: ${DATABASE_PASSWORD} + environment: + - DATABASE_URL=jdbc:postgresql://WIQ_DB:5432/wiq + - DATABASE_USER=${DATABASE_USER} + - DATABASE_PASSWORD=${DATABASE_PASSWORD} + networks: + - mynetwork + webapp: container_name: webapp-${teamname:-defaultASW} image: ghcr.io/arquisoft/wiq_en2b/webapp:latest diff --git a/questiongenerator/Dockerfile b/questiongenerator/Dockerfile new file mode 100644 index 00000000..6e6d725b --- /dev/null +++ b/questiongenerator/Dockerfile @@ -0,0 +1,19 @@ +FROM maven:3.8.1-openjdk-17 AS build +LABEL authors="dario" +# Compile api +COPY . /questiongenerator +WORKDIR /questiongenerator +RUN mvn install +RUN mvn clean package + +FROM amazoncorretto:17 AS runtime +# Copy the compiled jar file from the build stage +ARG DATABASE_USER +ARG DATABASE_PASSWORD + +# Set environment variables +ENV DATABASE_URL jdbc:postgresql://WIQ_DB:5432/wiq +ENV DATABASE_USER $DATABASE_USER +ENV DATABASE_PASSWORD $DATABASE_PASSWORD +COPY --from=build /api/target/QuestionGenerator-1.0-SNAPSHOT.jar app.jar +ENTRYPOINT ["java","-jar","app.jar"] \ No newline at end of file