diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index fa151303..13a536bf 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -1,8 +1,3 @@ -# This workflow should control anything to do with web frontend -# Including building the docker image and pushing it -# It should run on both development and production scenarios -# Production workflow (tagging the image as "latest") should run only on tagged version push - name: Web workflow on: @@ -48,10 +43,19 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Set SERVER_BASE_URL (tagged releases) + if: startsWith(github.ref, 'refs/tags/v') + run: echo "SERVER_BASE_URL=https://encyclo-flower.com/api/v1" >> $GITHUB_ENV + + - name: Set SERVER_BASE_URL (other triggers) + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: echo "SERVER_BASE_URL=https://dev.encyclo-flower.com/api/v1" >> $GITHUB_ENV + - name: Build and push uses: docker/build-push-action@v4 with: context: src/web + build-args: SERVER_BASE_URL=${{ env.SERVER_BASE_URL }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/server/docker-compose.yml b/server/docker-compose.yml index 144f5522..3fac5aae 100644 --- a/server/docker-compose.yml +++ b/server/docker-compose.yml @@ -50,8 +50,6 @@ services: restart: always env_file: - PRODUCTION.env - environment: - - SERVER_BASE_URL=https://encyclo-flower.com/api/v1 networks: - production @@ -60,8 +58,6 @@ services: restart: always env_file: - DEVELOPMENT.env - environment: - - SERVER_BASE_URL=https://dev.encyclo-flower.com/api/v1 networks: - production diff --git a/src/web/Dockerfile b/src/web/Dockerfile index 2d040c13..a9788951 100644 --- a/src/web/Dockerfile +++ b/src/web/Dockerfile @@ -12,7 +12,7 @@ FROM node:20-alpine3.18 as production WORKDIR /app COPY package*.json . -RUN npm ci --only=production +RUN npm ci --omit=dev COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public