Website infrastructure describes resources involved in front part of société numérique website.
This repository is NOT required for local development.
- 🪧 About
- 📦 Prerequisites
- 🚀 Installation
- 🛠️ Usage
- 🤝 Contribution
- 🏗️ Built with
- 📝 Licence
The following command allows to use the Terraform command line via Docker:
docker run --rm -it --name terraform -v ~/:/root/ -v $(pwd):/workspace -w /workspace hashicorp/terraform:light
For simplified use, you can create an alias:
alias terraform='docker run --rm -it --name terraform -v ~/:/root/ -v $(pwd):/workspace -w /workspace hashicorp/terraform:light'
Using this alias, there is no longer any difference between a terraform command executed via Docker or via Terraform CLI.
We can use the same trick to use Scaleway command line via Docker:
docker run --rm -it --name scaleway -v ~/:/root/ scaleway/cli:latest
For simplified use, you can create an alias:
alias scw='docker run --rm -it --name scaleway -v ~/:/root/ scaleway/cli:latest'
terraform fmt
terraform validate
terraform login
terraform init
Plan a run to check differences between the current and the next infrastructure state to be deployed
terraform plan
Simply push the changes to the main
branch, to apply the next state of the infrastructure in production.
- Terraform is an infrastructure as code software tool that allow to define and provide infrastructure using a declarative configuration language
- Github Actions is the continuous integration and deployment tool provided by GitHub
- Deployment history is available under Actions tab
- Repository secrets:
TF_API_TOKEN
: Terraform Cloud API token which allows the CI to operate actions on Terraform Cloud, you can create aTeam API Token
in your Terraform Cloud WorkspaceSettings
underTeams
menu.
- Terraform Cloud is a cloud platform provided by HashiCorp to host Terraform infrastructure state and apply changes
- Organization: societenumerique
- Workspaces :
website-*
- website-production
- Variables:
NEXT_PUBLIC_STRAPI_URL
terraform
The root url of the Content Management system, you can get this value in the outputs of infrastructure-content-management-system terraform run outputsPROJECT_ID
terraform
Scaleway project id: available in Societe Numerique project dashboard settingsREGISTRY_ENDPOINT
terraform
Scaleway registry endpoint: get the endpoint after creating docker registry and push the initial imageSCW_ACCESS_KEY
env
Scaleway access key: generate API key for your userSCW_SECRET_KEY
env
sensitive
Scaleway secret key: generate API key for your user
- Scaleway is a cloud provider platform provided by Scaleway
- Organization : Agence nationale de la cohésion des territoires
- Project: Societe Numerique
You need to complete this actions before the first run on the CI in order to get a ready to use docker registry endpoint with a first image ready to deploy.
Initialize scaleway CLI using Scaleway access and secret key you generated with the API key for your user:
scw init
Run the command below in a terminal to export your API access and secret keys as environment variables:
export SCW_ACCESS_KEY=$(scw config get access-key)
export SCW_SECRET_KEY=$(scw config get secret-key)
Go in initialized website
project (you should be able to run it locally) and run:
docker build -t website .
Run the following command to create a Container Registry namespace and export its endpoint as a variable:
export REGISTRY_ENDPOINT=$(scw registry namespace create -o json | jq -r '.endpoint')
Run the following command to log in to your Container Registry:
docker login $REGISTRY_ENDPOINT -u nologin --password-stdin <<< "$SCW_SECRET_KEY"
Tag and push your container image to your Container Registry namespace:
docker tag website:latest $REGISTRY_ENDPOINT/website:latest
docker push $REGISTRY_ENDPOINT/website:latest
See LICENSE.md file in this repository.