Skip to content

Commit

Permalink
docs: add deployment and required variables info
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gavanier committed Aug 15, 2024
1 parent e4ee178 commit e4e4c24
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
56 changes: 48 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,59 @@ Simply push the changes to the `main` branch, to apply the next state of the inf
#### CI

- [Github Actions](https://docs.github.com/en/actions) is the continuous integration and deployment tool provided by GitHub
- Deployment history is available [under Actions tab](https://github.com/marc-gavanier/marc-gavanier-client-infrastructure/actions)
- Deployment history is available [under Actions tab](https://github.com/societenumerique-gouv-fr/infrastructure-website/actions)
- Repository secrets:
- `TF_API_TOKEN`: Terraform Cloud API token which allows the CI to operate actions on Terraform Cloud
- `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

- [Terraform Cloud](https://app.terraform.io/) is a cloud platform provided by HashiCorp to host Terraform infrastructure state and apply changes
- Organization : [marc-gavanier](https://app.terraform.io/app/marc-gavanier/workspaces)
- Workspaces : `marc-gavanier-client-*`
- [marc-gavanier-client-production](https://app.terraform.io/app/marc-gavanier/workspaces/marc-gavanier-client-production)
- [AWS](https://aws.amazon.com/) is a cloud provider platform provided by Amazon
- User : `marc-gavanier.infrastructure.client`
- Group : `client.deployer`
- Organization: [societenumerique](https://app.terraform.io/app/societenumerique/workspaces)
- Workspaces : `website-*`
- [website-production](https://app.terraform.io/app/societe-numerique/workspaces/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](https://github.com/societenumerique-gouv-fr/infrastructure-content-management-system) terraform run outputs
- `PROJECT_ID` `terraform` Scaleway project id: [available in Societe Numerique project dashboard settings](https://console.scaleway.com/project/settings)
- `REGISTRY_ENDPOINT` `terraform` Scaleway registry endpoint: get the endpoint after [creating docker registry and push the initial image](#create-docker-registry-and-push-the-initial-image)
- `SCW_ACCESS_KEY` `env` Scaleway access key: [generate API key for your user](https://console.scaleway.com/iam/users)
- `SCW_SECRET_KEY` `env` `sensitive` Scaleway secret key: [generate API key for your user](https://console.scaleway.com/iam/users)
- [Scaleway](https://console.scaleway.com/) is a cloud provider platform provided by Scaleway
- Organization : Agence nationale de la cohésion des territoires
- Project: Societe Numerique

#### 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:
```bash
scw init
```
Run the command below in a terminal to export your API access and secret keys as environment variables:
```bash
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:
```bash
docker build -t website .
```

Run the following command to create a Container Registry namespace and export its endpoint as a variable:
```bash
export REGISTRY_ENDPOINT=$(scw registry namespace create -o json | jq -r '.endpoint')
```

Run the following command to log in to your Container Registry:
```bash
docker login $REGISTRY_ENDPOINT -u nologin --password-stdin <<< "$SCW_SECRET_KEY"
```

Tag and push your container image to your Container Registry namespace:
```bash
docker tag website:latest $REGISTRY_ENDPOINT/website:latest
docker push $REGISTRY_ENDPOINT/website:latest
```

## Licence

Expand Down
14 changes: 7 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
backend "remote" {
hostname = "app.terraform.io"
organization = "societe-numerique"
organization = "societenumerique"

workspaces {
prefix = "website-"
Expand All @@ -19,19 +19,19 @@ terraform {
required_version = ">= 0.13"
}

variable "REGISTRY_ENDPOINT" {
variable "NEXT_PUBLIC_STRAPI_URL" {
type = string
description = "Container Registry endpoint where your application container is stored"
description = "URL of the Strapi API serving data to display"
}

variable "DEFAULT_PROJECT_ID" {
variable "PROJECT_ID" {
type = string
description = "Project ID where your resources will be created"
}

variable "NEXT_PUBLIC_STRAPI_URL" {
variable "REGISTRY_ENDPOINT" {
type = string
description = "URL of the Strapi API serving data to display"
description = "Container Registry endpoint where your application container is stored"
}

locals {
Expand All @@ -41,7 +41,7 @@ locals {
resource "scaleway_container_namespace" "main" {
name = local.appName
description = "Namespace created for serverless Website deployment"
project_id = var.DEFAULT_PROJECT_ID
project_id = var.PROJECT_ID
}

resource "scaleway_container" "main" {
Expand Down

0 comments on commit e4e4c24

Please sign in to comment.