From 117cc126643a918527138ff8a4eef1e92d00253a Mon Sep 17 00:00:00 2001 From: Dario Date: Mon, 11 Mar 2024 23:58:18 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20question=20generator=20+=20fix=20for=20f?= =?UTF-8?q?ront=3F=20Co-authored-by:=20Gonzalo=20Su=C3=A1rez=20Losada=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 23 +++++++++++++++++++++-- docker-compose.yml | 16 ++++++++++++++++ questiongenerator/Dockerfile | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 questiongenerator/Dockerfile 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