Skip to content

societenumerique-gouv-fr/infrastructure-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Client infrastructure

About

Website infrastructure describes resources involved in front part of société numérique website.

This repository is NOT required for local development.

Table of contents

Prerequisites

Installation

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'

Usage

Check and fix .tf files format

terraform fmt

Verify ressources consistency

terraform validate

Retrieve Terraform Cloud authentication token locally

terraform login

Initialize state and plugins locally

terraform init

Plan a run to check differences between the current and the next infrastructure state to be deployed

terraform plan

Contribution

Apply the next state of the infrastructure

Simply push the changes to the main branch, to apply the next state of the infrastructure in production.

Built with

Langages & Frameworks

  • Terraform is an infrastructure as code software tool that allow to define and provide infrastructure using a declarative configuration language

Tools

CI

  • Github Actions is the continuous integration and deployment tool provided by GitHub
  • Repository secrets:
    • TF_API_TOKEN: Terraform Cloud API token which allows the CI to operate actions on Terraform Cloud, you can create a Team API Token in your Terraform Cloud Workspace Settings under Teams menu.

Deployment

Create docker registry and push the initial image

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

Licence

See LICENSE.md file in this repository.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages