Skip to content

Commit

Permalink
fix: Point to relevant backoffice URL according to deployment env (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens authored Sep 20, 2021
1 parent 8affa2c commit 5d088df
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 216 deletions.
210 changes: 3 additions & 207 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- v*

concurrency:
group: preproduction
group: production
cancel-in-progress: true

jobs:
Expand All @@ -28,55 +28,8 @@ jobs:
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}
imageName: nos1000jours/${{ env.project }}

# register:
# name: Build & Register images
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Get project name
# run: |
# echo "project=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

# - name: Create image labels and tags
# id: docker_meta
# uses: "crazy-max/ghaction-docker-meta@2e1a5c7fa42123697f82d479b551a1bbdb1bef88"
# with:
# images: ghcr.io/socialgouv/nos1000jours/${{ env.project }}
# labels: |
# org.opencontainers.image.title=${{ env.project }}
# org.opencontainers.image.documentation=https://github.com/SocialGouv/${{ env.project }}/tree/${{ github.sha }}
# tags: |
# type=sha
# type=ref,event=pr
# type=ref,event=branch
# type=semver,pattern={{version}}
# type=raw,value=sha-${{ github.sha }}
# type=semver,pattern={{major}}.{{minor}}

# - name: Set up Buildx
# id: buildx
# uses: docker/setup-buildx-action@master
# with:
# install: true

# - name: Registry authentication
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Image build and register
# uses: docker/build-push-action@v2
# with:
# context: .
# push: "true"
# builder: ${{ steps.buildx.outputs.name }}
# tags: "${{ steps.docker_meta.outputs.tags }}"
# labels: "${{ steps.docker_meta.outputs.labels }}"
dockerbuildargs: |
NEXT_PUBLIC_API_URL=https://backoffice-les1000jours.fabrique.social.gouv.fr
##############################################################################
## GENERATE PREPRODUCTION MANIFESTS
Expand All @@ -91,43 +44,6 @@ jobs:
with:
environment: "preprod"

# manifests:
# name: Preproduction manifests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Load preproduction environment variables
# run: |
# cat ".github/preproduction.env" >> $GITHUB_ENV

# - name: Yarn cache setup
# uses: c-hive/gha-yarn-cache@v1

# - name: Install kosko-charts autodevops
# run: |
# npx degit SocialGouv/kosko-charts/templates/autodevops /tmp/autodevops
# yarn --cwd /tmp/autodevops

# - name: Copy application k8s config to autodevops
# run: cp -r .socialgouv/environments .socialgouv/config.json /tmp/autodevops/

# - name: Generate k8s manifests
# run: |
# echo SOCIALGOUV_BASE_DOMAIN: $SOCIALGOUV_BASE_DOMAIN
# yarn --cwd /tmp/autodevops --silent generate:preprod > manifests.yml
# env:
# SOCIALGOUV_PREPRODUCTION: true
# SOCIALGOUV_CONFIG_PATH: /tmp/autodevops/config.json
# SOCIALGOUV_BASE_DOMAIN: ${{ env.SOCIALGOUV_BASE_DOMAIN }}

# - name: Archive k8s manifests
# uses: actions/upload-artifact@v2
# with:
# name: manifests.yml
# path: manifests.yml

##############################################################################
## DEPLOY PREPRODUCTION APPLICATION
##############################################################################
Expand All @@ -147,47 +63,6 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
kubeconfig: ${{ secrets.KUBECONFIG }}

# deploy:
# name: Deploy application
# runs-on: ubuntu-latest
# needs: [register, manifests]
# environment:
# name: preproduction
# url: https://${{ env.namespace }}.${{ env.SOCIALGOUV_BASE_DOMAIN }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Load environment variables
# run: |
# cat ".github/preproduction.env" >> $GITHUB_ENV
# echo "project=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
# echo "namespace=${GITHUB_REPOSITORY#*/}-preprod" >> $GITHUB_ENV

# - name: Download k8s manifests
# uses: actions/download-artifact@v2
# with:
# name: manifests.yml

# - name: Install Kapp
# uses: vmware-tanzu/carvel-setup-action@v1
# with:
# only: kapp
# token: ${{ secrets.GITHUB_TOKEN }}

# - name: Create kubernetes config
# run: |
# mkdir ~/.kube
# touch ~/.kube/config
# echo ${{ secrets.KUBECONFIG }} | base64 -d > ~/.kube/config

# - name: Create k8s namespace and annotations
# run: |
# kubectl create ns ${{ env.namespace }} || true

# - name: Deploy application
# run: kapp --dangerous-override-ownership-of-existing-resources -y deploy -a ${{ env.project }} --namespace ${{ env.namespace }} -f manifests.yml

##############################################################################
## GENERATE PRODUCTION MANIFESTS
##############################################################################
Expand All @@ -201,44 +76,6 @@ jobs:
with:
environment: "prod"

# manifests-prod:
# name: Production manifests
# runs-on: ubuntu-latest
# needs: deploy
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Load production environment variables
# run: |
# cat ".github/production.env" >> $GITHUB_ENV

# - name: Yarn cache setup
# uses: c-hive/gha-yarn-cache@v1

# - name: Install kosko-charts autodevops
# run: |
# npx degit SocialGouv/kosko-charts/templates/autodevops /tmp/autodevops
# yarn --cwd /tmp/autodevops

# - name: Copy application k8s config to autodevops
# run: cp -r .socialgouv/environments .socialgouv/config.json /tmp/autodevops/

# - name: Generate k8s manifests
# run: |
# echo SOCIALGOUV_BASE_DOMAIN: $SOCIALGOUV_BASE_DOMAIN
# yarn --cwd /tmp/autodevops --silent generate:prod > manifests-prod.yml
# env:
# SOCIALGOUV_PRODUCTION: true
# SOCIALGOUV_CONFIG_PATH: /tmp/autodevops/config.json
# SOCIALGOUV_BASE_DOMAIN: ${{ env.SOCIALGOUV_BASE_DOMAIN }}

# - name: Archive k8s manifests
# uses: actions/upload-artifact@v2
# with:
# name: manifests-prod.yml
# path: manifests-prod.yml

##############################################################################
## DEPLOY PRODUCTION APPLICATION
##############################################################################
Expand All @@ -257,44 +94,3 @@ jobs:
environment: "prod"
token: ${{ secrets.GITHUB_TOKEN }}
kubeconfig: ${{ secrets.KUBECONFIG }}

# deploy-prod:
# name: Deploy application
# runs-on: ubuntu-latest
# needs: manifests-prod
# environment:
# name: production
# url: https://${{ env.namespace }}.${{ env.SOCIALGOUV_BASE_DOMAIN }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Load environment variables
# run: |
# cat ".github/production.env" >> $GITHUB_ENV
# echo "project=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
# echo "namespace=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

# - name: Download k8s manifests
# uses: actions/download-artifact@v2
# with:
# name: manifests-prod.yml

# - name: Install Kapp
# uses: vmware-tanzu/carvel-setup-action@v1
# with:
# only: kapp
# token: ${{ secrets.GITHUB_TOKEN }}

# - name: Create kubernetes config
# run: |
# mkdir ~/.kube
# touch ~/.kube/config
# echo ${{ secrets.KUBECONFIG }} | base64 -d > ~/.kube/config

# - name: Create k8s namespace and annotations
# run: |
# kubectl create ns ${{ env.namespace }} || true

# - name: Deploy application
# run: kapp --dangerous-override-ownership-of-existing-resources -y deploy -a ${{ env.project }} --namespace ${{ env.namespace }} -f manifests-prod.yml
2 changes: 2 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}
imageName: nos1000jours/${{ env.project }}
dockerbuildargs: |
NEXT_PUBLIC_API_URL=https://backoffice-preprod-les1000jours.dev.fabrique.social.gouv.fr
##############################################################################
## GENERATE KUBERNETES MANIFESTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ data:
NODE_ENV: "production"
MATOMO_SITE_ID: "47"
MATOMO_URL: "https://matomo.fabrique.social.gouv.fr/"
API_URL: "backoffice-develop-dev-les1000jours.dev.fabrique.social.gouv.fr"
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ data:
NODE_ENV: "production"
MATOMO_SITE_ID: "47"
MATOMO_URL: "https://matomo.fabrique.social.gouv.fr/"
API_URL: "backoffice-preprod-les1000jours.dev.fabrique.social.gouv.fr"
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ data:
NODE_ENV: "production"
MATOMO_SITE_ID: "47"
MATOMO_URL: "https://matomo.fabrique.social.gouv.fr/"
API_URL: "backoffice-les1000jours.fabrique.social.gouv.fr"
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ FROM node:15.9-alpine

WORKDIR /app

COPY . /app/
COPY . .

ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL

RUN yarn --production --frozen-lockfile --prefer-offline && yarn cache clean
RUN yarn build
Expand Down
5 changes: 1 addition & 4 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ module.exports = {
},
]
},
env: {
API_URL: process.env.API_URL
}
}
}
2 changes: 1 addition & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const STORAGE_RESULTS_BOARD = "resultsBoard";

export const PATTERN_EMAIL = "[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z.]{2,15}";

export const API_URL = process.env.API_URL ? process.env.API_URL : "https://backoffice-develop-dev-les1000jours.dev.fabrique.social.gouv.fr";
export const API_URL = process.env.NEXT_PUBLIC_API_URL || "https://backoffice-develop-dev-les1000jours.dev.fabrique.social.gouv.fr";
export const URL_1000J = "https://1000jours.fabrique.social.gouv.fr";
export const EPDS_SOURCE = "SiteWebPro"

Expand Down

0 comments on commit 5d088df

Please sign in to comment.