Skip to content

Commit

Permalink
feat(spa-nginx): add spa nginx image (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Nov 8, 2019
1 parent a1e082b commit f642a9c
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $ docker pull docker.pkg.github.com/socialgouv/docker/<image>:<version>
| **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) |

<br>
<br>
Expand Down
18 changes: 18 additions & 0 deletions spa-nginx/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions spa-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:1.17

COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions spa-nginx/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 <env-vars

rm env-vars

#########################
# Step 2 : Start NGINX #
#########################

exec nginx -g 'daemon off;'
48 changes: 48 additions & 0 deletions spa-nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
user nginx;
worker_processes auto; # it will be determinate automatically by the number of core

error_log /var/log/nginx/error.log warn;

events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
keepalive_timeout 3000;
absolute_redirect off;

server {
listen 80;
root /usr/share/nginx/html;
index index.html;
server_name_in_redirect on;

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/css application/json application/javascript application/x-javascript text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

client_max_body_size 32m;
error_page 500 502 503 504 /50x.html;

location / {
try_files $uri $uri/ /index.html;
}

location /50x.html {
root /var/lib/nginx/html;
}

}
}

0 comments on commit f642a9c

Please sign in to comment.