[damned-lies] chore: merge staging/production
- From: Guillaume Bernard <gbernard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] chore: merge staging/production
- Date: Tue, 10 May 2022 08:30:02 +0000 (UTC)
commit 9e6b5fd853b40f43e2b46b3c7609402d81ed0e1e
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Mon May 9 15:06:23 2022 +0200
chore: merge staging/production
Staging artifacts should be the same, to respect reproductibility
principles. So I move the SITE_DOMAIN parameter to a ENV variable and
merged all the ALLOWED_HOSTS values.
There remain only test and production envs.
.gitlab-ci.yml | 50 ++++++----------------
containers/production/.gitignore | 1 -
containers/production/build_buildah_deployment.sh | 2 +-
...uild_buildah_replace_staging_with_production.sh | 44 -------------------
.../production/configuration/entrypoint.sh.jinja2 | 4 ++
.../production/configuration/httpd.conf.jinja2 | 6 +--
.../configuration/local_settings.py.jinja2 | 5 +--
.../production/configuration/production.json | 17 ++++----
containers/production/configuration/staging.json | 39 -----------------
containers/production/configuration/test.json | 12 +++---
.../production/render_configuration_templates.sh | 2 +-
11 files changed, 36 insertions(+), 146 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index da57a214..9d250c89 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,8 +4,6 @@ stages:
# Build all artefacts that may be published or put to production such as packages or containers
- build
- test
- # Pre deploy tasks such as building final production images, etc.
- - pre_deploy
# Deploy to staging environment
- staging
# Deploy to production environment
@@ -136,17 +134,27 @@ package:
expire_in: 1 week
-build_container:staging:
+build_container:production:
extends: .build_damned_lies_image
stage: build
- variables:
- KIND_OF_DEPLOYMENT: "staging"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- when: never
+build_container:test:
+ extends: .build_damned_lies_image
+ stage: build
+ variables:
+ KIND_OF_DEPLOYMENT: "test"
+ rules:
+ - if: $CI_COMMIT_BRANCH == "develop"
+ when: always
+ - when: never
+
+
+
##############################################################################
################### Test ###################
##############################################################################
@@ -234,38 +242,6 @@ code-string-changes:
when: on_failure
-##############################################################################
-################### Pre Deploy ###################
-##############################################################################
-build_container:test:
- extends: .build_damned_lies_image
- stage: pre_deploy
- variables:
- KIND_OF_DEPLOYMENT: "test"
- rules:
- - if: $CI_COMMIT_BRANCH == "develop"
- when: always
- - when: never
-
-
-build_container:production:
- extends: .build_damned_lies_image
- stage: pre_deploy
- variables:
- KIND_OF_DEPLOYMENT: "production"
- DAMNED_LIES_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/damned-lies-production"
- IMAGE_TAG: "${CI_REGISTRY_IMAGE}/damned-lies-production:${CI_COMMIT_REF_NAME}"
- script:
- - dnf install -y python3-jinja2-cli
- - ./containers/production/render_configuration_templates.sh "${KIND_OF_DEPLOYMENT}"
- - ./containers/production/build_buildah_replace_staging_with_production.sh
- - buildah push "${IMAGE_TAG}-${KIND_OF_DEPLOYMENT}"
- rules:
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- when: always
- - when: never
-
-
##############################################################################
################### Staging ###################
##############################################################################
diff --git a/containers/production/.gitignore b/containers/production/.gitignore
index 21b384b0..69b120b8 100644
--- a/containers/production/.gitignore
+++ b/containers/production/.gitignore
@@ -1,3 +1,2 @@
production
-staging
test
diff --git a/containers/production/build_buildah_deployment.sh
b/containers/production/build_buildah_deployment.sh
index 1ed24bb7..59552752 100755
--- a/containers/production/build_buildah_deployment.sh
+++ b/containers/production/build_buildah_deployment.sh
@@ -31,7 +31,7 @@ if [[ -z ${RUNTIME_IMAGE_NAME+x} ]]; then
fi
# KIND_OF_DEPLOYMENT: kind of image to build (the configuration will depend on this parameter).
-# Possible values are test, staging or production (the default), the names of the configuration files in JSON
+# Possible values are test, production (the default), the names of the configuration files in JSON
declare KIND_OF_DEPLOYMENT="${1:-"production"}"
#######################################################################################################################
diff --git a/containers/production/configuration/entrypoint.sh.jinja2
b/containers/production/configuration/entrypoint.sh.jinja2
index d9967a78..b8f40d4a 100755
--- a/containers/production/configuration/entrypoint.sh.jinja2
+++ b/containers/production/configuration/entrypoint.sh.jinja2
@@ -4,6 +4,7 @@ declare -r LOCAL_SETTINGS_FILE="{{ damned_lies_project_directory }}/damnedlies/l
declare -r SSH_CONFIG_URL="https://gitlab.gnome.org/Infrastructure/damned-lies/-/raw/oscp/httpd/ssh_config"
{% if kind == "production" %}
+# Database configuration
sed -i "s/\$DB_NAME/${DB_NAME}/" "${LOCAL_SETTINGS_FILE}"
sed -i "s/\$DB_USER/${DB_USER}/" "${LOCAL_SETTINGS_FILE}"
sed -i "s/\$DB_PASSWORD/${DB_PASSWORD}/" "${LOCAL_SETTINGS_FILE}"
@@ -13,6 +14,9 @@ sed -i "s/\$SECRET_KEY/${SECRET_KEY}/" "${LOCAL_SETTINGS_FILE}"
sed -i "s/\$SENTRY_DSN/${SENTRY_DSN}/" "${LOCAL_SETTINGS_FILE}"
sed -i "s/\$GITLAB_TOKEN/${GITLAB_TOKEN}/" "${LOCAL_SETTINGS_FILE}"
+# The domain under which the application is publicly available
+sed -i "s/\$SITE_DOMAIN/${SITE_DOMAIN}/" "${LOCAL_SETTINGS_FILE}"
+
echo "Populating .ssh for the {{ process.user }} user"
mkdir -p "${HOME}/.ssh"
ln -s "${HOME}/.ssh_secret/ssh-privatekey" "${HOME}/.ssh/ssh-privatekey"
diff --git a/containers/production/configuration/httpd.conf.jinja2
b/containers/production/configuration/httpd.conf.jinja2
index 68f3bb6f..77819ba3 100644
--- a/containers/production/configuration/httpd.conf.jinja2
+++ b/containers/production/configuration/httpd.conf.jinja2
@@ -1,8 +1,4 @@
-<VirtualHost *:8080>
- ServerName {{ server.name }}
- {% for alias in server.aliases %}
- ServerAlias {{ alias }}
- {% endfor %}
+<VirtualHost _default_:8080>
Alias /HTML {{ damned_lies_data_directory }}/scratchdir/HTML
Alias /POT {{ damned_lies_data_directory }}/scratchdir/POT
diff --git a/containers/production/configuration/local_settings.py.jinja2
b/containers/production/configuration/local_settings.py.jinja2
index c75de696..e7ad3713 100644
--- a/containers/production/configuration/local_settings.py.jinja2
+++ b/containers/production/configuration/local_settings.py.jinja2
@@ -37,10 +37,9 @@ DEBUG = False
SECRET_KEY = """$SECRET_KEY"""
-SITE_DOMAIN = "{{ server.name }}"
+SITE_DOMAIN = """$SITE_DOMAIN"""
ALLOWED_HOSTS = [
- "{{ server.name }}",
-{% for server_alias in server.aliases %}
+{% for server_alias in server_aliases %}
"{{ server_alias }}",
{% endfor %}
]
diff --git a/containers/production/configuration/production.json
b/containers/production/configuration/production.json
index a081bbe2..9dff4c78 100644
--- a/containers/production/configuration/production.json
+++ b/containers/production/configuration/production.json
@@ -1,12 +1,13 @@
{
- "server": {
- "name": "l10n.gnome.org",
- "aliases": [
- "8.43.85.13",
- "8.43.85.14",
- "8.43.85.29"
- ]
- },
+ "server_aliases": [
+ "l10n.gnome.org",
+ "l10n-staging.openshift.gnome.org",
+ "8.43.85.13",
+ "8.43.85.14",
+ "8.43.85.29",
+ "127.0.0.1",
+ "localhost"
+ ],
"kind": "production",
"damned_lies_project_directory": "/l10n/damnedlies",
"damned_lies_data_directory": "/var/www/djamnedlies/data",
diff --git a/containers/production/configuration/test.json b/containers/production/configuration/test.json
index d27af9e5..de6a1242 100644
--- a/containers/production/configuration/test.json
+++ b/containers/production/configuration/test.json
@@ -1,11 +1,9 @@
{
- "server": {
- "name": "l10n-testing.openshift.gnome.org",
- "aliases": [
- "127.0.0.1",
- "localhost"
- ]
- },
+ "server_aliases": [
+ "l10n-testing.openshift.gnome.org",
+ "127.0.0.1",
+ "localhost"
+ ],
"kind": "test",
"damned_lies_project_directory": "/l10n/damnedlies",
"damned_lies_data_directory": "/var/www/djamnedlies/data",
diff --git a/containers/production/render_configuration_templates.sh
b/containers/production/render_configuration_templates.sh
index 5742aa80..e4e2b52b 100755
--- a/containers/production/render_configuration_templates.sh
+++ b/containers/production/render_configuration_templates.sh
@@ -5,7 +5,7 @@
set +C
# KIND_OF_DEPLOYMENT: kind of deployment to render (the configuration will depend on this parameter).
-# Possible values are test, staging or production (the default), the names of the configuration files in JSON
+# Possible values are test or production (the default), the names of the configuration files in JSON
declare -r KIND_OF_DEPLOYMENT="${1:-production}"
# THIS_SCRIPT_DIRECTORY: the current script directory name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]