Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/v2 fix for env vars #1844

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions .env.default
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
NEXT_PUBLIC_ADRESSE_URL=http://localhost:3000
NEXT_PUBLIC_API_BAN_URL=https://plateforme.adresse.data.gouv.fr

# -----------------------------
# Application configuration ---
# -----------------------------

# Defintion du port
PORT=3000
# Fonctionnalité: Certificat d'addressage (Valeur 0 ou 1)
NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=0
# DEPRECATED : A voir pour supprimer cette variable qui utilise la lib helmet
ENABLE_HELMET=0

# -----------------------------------------------
# --- Parametres URL Externe autre projet BAN ---
# -----------------------------------------------

NEXT_PUBLIC_API_GEO_URL=https://geo.api.gouv.fr/2024
NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC=https://api-lannuaire.service-public.fr/api/explore/v2.1
NEXT_PUBLIC_DATAGOUV_URL=https://www.data.gouv.fr/api/1

NEXT_PUBLIC_API_BAN_URL=https://plateforme.adresse.data.gouv.fr
# API search for Addok Geocodeur
NEXT_PUBLIC_API_ADRESSE=https://api-adresse.data.gouv.fr
NEXT_LAST_UPDATED_DATE_ADDOCK_URL='https://api-adresse.data.gouv.fr/info.txt'

# -------------------------------------
# --- Utilisation appel externe Bal ---
# -------------------------------------

# API Depot
NEXT_PUBLIC_API_DEPOT_URL=https://plateforme-bal.adresse.data.gouv.fr/api-depot
API_DEPOT_TOKEN=
SESSION_SECRET=

# Params pour la partie Blog
NEXT_PUBLIC_GHOST_URL=https://ghost.adresse.data.gouv.fr
NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=ghost.adresse.data.gouv.fr
NEXT_PUBLIC_GHOST_KEY=xxxx
NEXT_PUBLIC_GHOST_KEY=YOUR_GHOST_KEY_HERE

# Definition URL pour accès aux sites BAL

NEXT_PUBLIC_BAL_ADMIN_API_URL=https://bal-admin.adresse.data.gouv.fr/api
NEXT_PUBLIC_BAL_API_URL=https://api-bal.adresse.data.gouv.fr/v2
NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL=https://plateforme-bal.adresse.data.gouv.fr/moissonneur
Expand All @@ -34,37 +46,28 @@ NEXT_PUBLIC_BAL_WIDGET_URL=https://baseadressenationale.github.io/bal-widget
NEXT_PUBLIC_CLIENT_GUICHET_ADRESSE=
NEXT_PUBLIC_CLIENT_MES_ADRESSE=
NEXT_PUBLIC_CLIENT_FORMULAIRE_PUBLICATION=
NEXT_PUBLIC_DATAGOUV_URL=https://www.data.gouv.fr/api/1

# -----------------------------------------
# --- Utilisation Matomo pour les stats ---
# -----------------------------------------

NEXT_PUBLIC_MATOMO_URL=
NEXT_PUBLIC_MATOMO_SITE_ID=
# The Matomo Token is actualy not required
# MATOMO_TOKEN_AUTH=

# A voir pour supprimer cette variable qui utilise la lib helmet
ENABLE_HELMET=0

# Defintion du port
PORT=3000

# Valeur 0 ou 1 pour la demande de certification
NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=

# --------------------------------------
# --- Connexion au S3 pour les datas ---
# --------------------------------------

S3_CONFIG_ACCESS_KEY_ID=xxxx
S3_CONFIG_SECRET_ACCESS_KEY=xxxx
S3_CONFIG_REGION=xxxx
S3_CONFIG_ENDPOINT=xxxx
S3_CONFIG_ACCESS_KEY_ID=YOUR_S3_ACCESS_KEY_ID_HERE
S3_CONFIG_SECRET_ACCESS_KEY=YOUR_S3_SECRET_ACCESS_KEY_HERE
S3_CONFIG_REGION=YOUR_S3_REGION_HERE
S3_CONFIG_ENDPOINT=YOUR_S3_ENDPOINT_HERE

# Connexion au Dossier Data local (en cas de rollback - TOGGLER_DATA_SOURCES=local sinon TOGGLER_DATA_SOURCES=S3)
NEXT_PUBLIC_TOGGLER_DATA_SOURCES=S3
NEXT_PUBLIC_PATH_STATIC_FILE=
# DEPRECATED : Connexion au Dossier Data local (en cas de rollback - TOGGLER_DATA_SOURCES=local sinon TOGGLER_DATA_SOURCES=S3)
# NEXT_PUBLIC_TOGGLER_DATA_SOURCES=S3
# NEXT_PUBLIC_PATH_STATIC_FILE=

# -------------------------------
# --- URL des réseaux sociaux ---
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ env:
NEXT_PUBLIC_API_DEPOT_URL: ${{ vars.NEXT_PUBLIC_API_DEPOT_URL }}
NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC: ${{ vars.NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC }}
NEXT_PUBLIC_BAL_API_URL: ${{ vars.NEXT_PUBLIC_BAL_API_URL }}
NEXT_PUBLIC_GHOST_URL: ${{ vars.NEXT_PUBLIC_GHOST_URL }}
NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE: ${{ vars.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE }}
NEXT_PUBLIC_GHOST_KEY: ${{ vars.NEXT_PUBLIC_GHOST_KEY }}

# S3 Configuration
S3_CONFIG_ACCESS_KEY_ID: ${{ secrets.S3_CONFIG_ACCESS_KEY_ID }}
S3_CONFIG_SECRET_ACCESS_KEY: ${{ secrets.S3_CONFIG_SECRET_ACCESS_KEY }}
S3_CONFIG_REGION: ${{ secrets.S3_CONFIG_REGION }}
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: Docker

on:
push:
branches:
branches:
- "master"
- "main" # Ajout de la branche main
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches:
branches:
- "master"
- "main" # Ajout de la branche main

Expand All @@ -17,6 +17,21 @@ env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
# App Configuration
NEXT_PUBLIC_ADRESSE_URL: ${{ vars.NEXT_PUBLIC_ADRESSE_URL }}
NEXT_PUBLIC_API_BAN_URL: ${{ vars.NEXT_PUBLIC_API_BAN_URL }}
# DataGouv & Beta.gouv API Configuration
NEXT_PUBLIC_DATAGOUV_URL: ${{ vars.NEXT_PUBLIC_DATAGOUV_URL }}
NEXT_PUBLIC_API_GEO_URL: ${{ vars.NEXT_PUBLIC_API_GEO_URL }}
NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC: ${{ vars.NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC }}
# Ghost Blog Configuration
NEXT_PUBLIC_GHOST_URL: ${{ vars.NEXT_PUBLIC_GHOST_URL }}
NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE: ${{ vars.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE }}
NEXT_PUBLIC_GHOST_KEY: ${{ vars.NEXT_PUBLIC_GHOST_KEY }}
# BAL API Access Configuration
NEXT_PUBLIC_API_DEPOT_URL: ${{ vars.NEXT_PUBLIC_API_DEPOT_URL }}
NEXT_PUBLIC_BAL_ADMIN_API_URL: ${{ vars.NEXT_PUBLIC_BAL_ADMIN_API_URL }}
NEXT_PUBLIC_BAL_API_URL: ${{ vars.NEXT_PUBLIC_BAL_API_URL }}

jobs:
build:
Expand Down Expand Up @@ -74,4 +89,4 @@ jobs:
- name: Print Debug Info
run: |
echo "Registry: ${{ env.REGISTRY }}"
echo "Image Name: ${{ env.IMAGE_NAME }}"
echo "Image Name: ${{ env.IMAGE_NAME }}"
44 changes: 29 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.8'
services:
frontend:
build:
dockerfile: "dockerfile.dev"
dockerfile: "dockerfile.dev"
container_name: frontend-new-site
volumes:
- ./public:/app/public
Expand All @@ -18,34 +18,48 @@ services:
- ./.next:/app/.next
- ./.storybook:/app/.storybook
ports:
- "3000:3000"
- "3000:3000"
environment:
- NEXT_PUBLIC_ADRESSE_URL=${NEXT_PUBLIC_ADRESSE_URL}
- NEXT_PUBLIC_API_GEO_URL=${NEXT_PUBLIC_API_GEO_URL}
- NEXT_PUBLIC_API_BAN_URL=${NEXT_PUBLIC_API_BAN_URL}
- NEXT_PUBLIC_API_ADRESSE=${NEXT_PUBLIC_API_ADRESSE}
- NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC=${NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC}
- NEXT_PUBLIC_MATOMO_URL=${NEXT_PUBLIC_MATOMO_URL}
- NEXT_PUBLIC_MATOMO_SITE_ID=${NEXT_PUBLIC_MATOMO_SITE_ID}
- MATOMO_TOKEN_AUTH=${MATOMO_TOKEN_AUTH}
# App Configuration
- NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=${NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED}
- ENABLE_HELMET=${ENABLE_HELMET}
# External URLs
- NEXT_PUBLIC_API_GEO_URL=${NEXT_PUBLIC_API_GEO_URL}
- NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC=${NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC}
- NEXT_PUBLIC_DATAGOUV_URL=${NEXT_PUBLIC_DATAGOUV_URL}
# API search for Addok Geocodeur
- NEXT_PUBLIC_API_ADRESSE=${NEXT_PUBLIC_API_ADRESSE}
- NEXT_LAST_UPDATED_DATE_ADDOCK_URL=${NEXT_LAST_UPDATED_DATE_ADDOCK_URL}
# BAL - API Depot Access Configuration
- NEXT_PUBLIC_API_DEPOT_URL=${NEXT_PUBLIC_API_DEPOT_URL}
- API_DEPOT_TOKEN=${API_DEPOT_TOKEN}
- SESSION_SECRET=${SESSION_SECRET}
- NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=${NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED}
- GHOST_KEY=${GHOST_KEY}
# Blog Configuration
- NEXT_PUBLIC_GHOST_KEY=${GHOST_KEY}
- NEXT_PUBLIC_GHOST_URL=${NEXT_PUBLIC_GHOST_URL}
- NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=${NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE}
# BAL environements parameters
- NEXT_PUBLIC_BAL_ADMIN_API_URL=${NEXT_PUBLIC_BAL_ADMIN_API_URL}
- NEXT_PUBLIC_BAL_API_URL=${NEXT_PUBLIC_BAL_API_URL}
- NEXT_PUBLIC_BAL_WIDGET_URL=${NEXT_PUBLIC_BAL_WIDGET_URL}
- NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL=${NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL}
- NEXT_PUBLIC_MES_ADRESSES=${NEXT_PUBLIC_MES_ADRESSES}
- NEXT_PUBLIC_TOGGLER_DATA_SOURCES=${NEXT_PUBLIC_TOGGLER_DATA_SOURCES}
- NEXT_PUBLIC_PATH_STATIC_FILE=${NEXT_PUBLIC_PATH_STATIC_FILE}
- NEXT_PUBLIC_BAL_WIDGET_URL=${NEXT_PUBLIC_BAL_WIDGET_URL}
- NEXT_PUBLIC_CLIENT_GUICHET_ADRESSE=${NEXT_PUBLIC_CLIENT_GUICHET_ADRESSE}
- NEXT_PUBLIC_CLIENT_MES_ADRESSE=${NEXT_PUBLIC_CLIENT_MES_ADRESSE}
- NEXT_PUBLIC_CLIENT_FORMULAIRE_PUBLICATION=${NEXT_PUBLIC_CLIENT_FORMULAIRE_PUBLICATION}
# Matomo Configuration
- NEXT_PUBLIC_MATOMO_URL=${NEXT_PUBLIC_MATOMO_URL}
- NEXT_PUBLIC_MATOMO_SITE_ID=${NEXT_PUBLIC_MATOMO_SITE_ID}
# S3 Configuration
- S3_CONFIG_ACCESS_KEY_ID=${S3_CONFIG_ACCESS_KEY_ID}
- S3_CONFIG_SECRET_ACCESS_KEY=${S3_CONFIG_SECRET_ACCESS_KEY}
- S3_CONFIG_REGION=${S3_CONFIG_REGION}
- S3_CONFIG_ENDPOINT=${S3_CONFIG_ENDPOINT}
- NEXT_LAST_UPDATED_DATE_ADDOCK_URL=${NEXT_LAST_UPDATED_DATE_ADDOCK_URL}
- NEXT_PUBLIC_DATAGOUV_URL=${NEXT_PUBLIC_DATAGOUV_URL}
# Social Networks
- NEXT_PUBLIC_SOCIAL_NETWORKS_URL_XCOM=${NEXT_PUBLIC_SOCIAL_NETWORKS_URL_XCOM}
- NEXT_PUBLIC_SOCIAL_NETWORKS_URL_FACEBOOK=${NEXT_PUBLIC_SOCIAL_NETWORKS_URL_FACEBOOK}
- NEXT_PUBLIC_SOCIAL_NETWORKS_URL_LINKEDIN=${NEXT_PUBLIC_SOCIAL_NETWORKS_URL_LINKEDIN}
- NEXT_PUBLIC_SOCIAL_NETWORKS_URL_GITHUB=${NEXT_PUBLIC_SOCIAL_NETWORKS_URL_GITHUB}

17 changes: 17 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/** @type {import('next').NextConfig} */

import fs from 'node:fs'
import NextBundleAnalyzer from '@next/bundle-analyzer'
import dotenv from 'dotenv'

const getNextEnv = envVars => Object.fromEntries(
Object
.entries(envVars)
.filter(([key]) => key.startsWith('NEXT_PUBLIC'))
)

const defaultEnvVarFile = '.env.default'
const defaultEnvVarRaw = dotenv.parse(fs.readFileSync(defaultEnvVarFile))
const defaultEnvVar = getNextEnv(defaultEnvVarRaw)
const envVar = getNextEnv(process.env)

const NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE = process.env.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE
const imagesDomains = ['static.data.gouv.fr']
Expand All @@ -13,6 +26,10 @@ const withBundleAnalyzer = NextBundleAnalyzer({
})

const nextConfig = withBundleAnalyzer({
env: {
...defaultEnvVar,
...envVar,
},
images: {
remotePatterns: imagesDomains.map(domain => ({
protocol: 'https',
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@socialgouv/matomo-next": "^1.9.0",
"@types/remark-heading-id": "^1.0.0",
"chart.js": "^4.4.4",
"dotenv": "^16.4.5",
"filesize": "^10.1.6",
"geojson-vt": "^4.0.2",
"gray-matter": "^4.0.3",
Expand Down
Loading