diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..298d48b --- /dev/null +++ b/.env.development @@ -0,0 +1,12 @@ +AUTH_KEYCLOAK_ID=nextjs +AUTH_KEYCLOAK_SECRET=MDOgE836RmNGmaHDhzH9rNjK2i4QB7ph +AUTH_KEYCLOAK_ISSUER=http://localhost.jaqpot.org:8070/realms/jaqpot-local +NEXT_PUBLIC_AUTH_KEYCLOAK_ISSUER=${AUTH_KEYCLOAK_ISSUER} +NEXT_PUBLIC_AUTH_KEYCLOAK_ID=${AUTH_KEYCLOAK_ID} + +AUTH_URL=http://localhost.jaqpot.org:3000 +AUTH_SECRET=n43NFbC4xzE4LKcigNl6N353ouZcT5tHDh29ahw7/dg= + +API_URL="http://localhost.jaqpot.org:8080" + +NEXT_PUBLIC_GA_MEASUREMENT_ID="G-VW0RC3JS55" diff --git a/.env b/.env.production similarity index 100% rename from .env rename to .env.production diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml new file mode 100644 index 0000000..ec4b3fb --- /dev/null +++ b/.github/workflows/publish-dev.yml @@ -0,0 +1,45 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker dev image + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: upcintua/jaqpot-frontend-development + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + build-args: | + DEPLOYMENT_ENV=development + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 3d1b852..e95b626 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM node:18-alpine AS base +# Add build argument +ARG DEPLOYMENT_ENV=production # Install dependencies only when needed FROM base AS deps @@ -21,6 +23,8 @@ FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . +# This trick will deploy the correct .env file based on the DEPLOYMENT_ENV build argument +COPY .env.${DEPLOYMENT_ENV} .env.production # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry