From f642a9c9ff3f8ad49385cddd4b61c5d1e4996cc2 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Fri, 8 Nov 2019 16:50:07 +0100 Subject: [PATCH] feat(spa-nginx): add spa nginx image (#31) --- .gitlab-ci.yml | 2 ++ README.md | 1 + spa-nginx/.gitlab-ci.yml | 18 +++++++++++++++ spa-nginx/Dockerfile | 6 +++++ spa-nginx/entrypoint.sh | 25 +++++++++++++++++++++ spa-nginx/nginx.conf | 48 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 spa-nginx/.gitlab-ci.yml create mode 100644 spa-nginx/Dockerfile create mode 100644 spa-nginx/entrypoint.sh create mode 100644 spa-nginx/nginx.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a08bc667a..849c341cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,8 @@ include: - /helm/.gitlab-ci.yml - /k8s-ns-killer/.gitlab-ci.yml - /kubectl/.gitlab-ci.yml + - /spa-nginx/.gitlab-ci.yml + # variables: diff --git a/README.md b/README.md index 9ba3574fe..1aa15448a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ $ docker pull docker.pkg.github.com/socialgouv/docker/: | **helm** | `docker pull registry.gitlab.factory.social.gouv.fr/socialgouv/docker/helm:0.9.1` | [![README](https://img.shields.io/badge/README--green.svg)](./helm/README.md) | | **k8s-ns-killer** | `docker pull registry.gitlab.factory.social.gouv.fr/socialgouv/docker/k8s-ns-killer:0.9.1` | [![README](https://img.shields.io/badge/README--green.svg)](./k8s-ns-killer/README.md) | | **kubectl** | `docker pull registry.gitlab.factory.social.gouv.fr/socialgouv/docker/kubectl:0.9.1` | [![README](https://img.shields.io/badge/README--green.svg)](./kubectl/README.md) | +| **spa-nginx** | `docker pull registry.gitlab.factory.social.gouv.fr/socialgouv/docker/spa-nginx:0.9.1` | [![README](https://img.shields.io/badge/README--green.svg)](./spa-nginx/README.md) |

diff --git a/spa-nginx/.gitlab-ci.yml b/spa-nginx/.gitlab-ci.yml new file mode 100644 index 000000000..4a4bafc25 --- /dev/null +++ b/spa-nginx/.gitlab-ci.yml @@ -0,0 +1,18 @@ +Build socialgouv/docker/spa-nginx: + stage: "Build" + extends: .base_register_to_gitlab_stage + variables: + CONTEXT: spa-nginx + IMAGE_NAME: ${CI_REGISTRY_IMAGE}/spa-nginx + +Test socialgouv/docker/spa-nginx: + stage: "Test" + image: "${CI_REGISTRY_IMAGE}/spa-nginx:${CI_COMMIT_SHA}" + environment: feature-dev + script: + - echo "todo..." + +Publish socialgouv/docker/spa-nginx to Github Registry: + extends: .base_publish_to_github_stage + variables: + IMAGE_NAME: socialgouv/docker/spa-nginx diff --git a/spa-nginx/Dockerfile b/spa-nginx/Dockerfile new file mode 100644 index 000000000..15165e504 --- /dev/null +++ b/spa-nginx/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:1.17 + +COPY ./nginx.conf /etc/nginx/nginx.conf +COPY ./entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/spa-nginx/entrypoint.sh b/spa-nginx/entrypoint.sh new file mode 100644 index 000000000..fb37a7e2f --- /dev/null +++ b/spa-nginx/entrypoint.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +ROOT_DIRECTORY="/usr/share/nginx/html" + +############################################################## +# Step 1 : replace default environment values in .html files # +############################################################## + +# Save env variable in file +printenv >> env-vars + +while IFS='=' read -r KEY VALUE +do + # replace default environment variables value + find $ROOT_DIRECTORY -type f -name \*.js -exec \ + sed -i -e "s|%%$KEY%%|$VALUE|g" {} + +done