Skip to content

Commit

Permalink
feat: deploy different image per environment (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv authored Jul 12, 2024
1 parent 8cc6e9e commit 0c4dbf3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -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"
File renamed without changes.
45 changes: 45 additions & 0 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0c4dbf3

Please sign in to comment.