Commit 0c67543c authored by Morbi's avatar Morbi

basic dockerfile

parent 6c669609
Pipeline #21 passed with stages
in 7 minutes and 24 seconds
......@@ -4,7 +4,10 @@ stages:
- install
- test
- build
- deploy
- release
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
cache:
key: "$CI_BUILD_REF_NAME" #chache per branch
......@@ -15,8 +18,8 @@ cache:
get dependencies:
stage: install
script:
- npm install
- npx bower install --allow-root
- npm install
- npx bower install --allow-root
lint:
stage: test
......@@ -33,3 +36,16 @@ build release:
- build
only:
- tags
docker release:
stage: release
image: docker:latest
cache:
paths:
- disabled
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
only:
- tags
FROM alpine
RUN apk add --no-cache openssl nginx
ENV DOCKERIZE_VERSION v0.6.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN mkdir "/run/nginx"
ADD docs/nginx.template.conf /etc/nginx/conf.d/default.tmpl
COPY build /var/www/donate
EXPOSE 80
CMD ["dockerize", "-template", "/etc/nginx/conf.d/default.tmpl:/etc/nginx/conf.d/default.conf", "-stdout", "/var/log/nginx/access.log", "-stderr", "/var/log/nginx/error.log", "-poll", "nginx"]
......@@ -17,4 +17,7 @@ npm run wcinstall paper-checkbox
# deploy
rsync -avz build/ cct-services:/var/www/donate/
# start docker container
docker run -p 8080:80 -e API_URL=https://sandbox.api.sangha.techcultivation.org/v1 registry.gitlab.techcultivation.org/sangha/sangha-donate
```
version: '2'
services:
sangha-donate:
image: sangha/sangha-donate
ports:
- 8080:80
environment:
- API_URL=https://sandbox.api.sangha.techcultivation.org/v1
- RENDERTRON_URL=http://rendertron:8080/render/
rendertron:
image: samdotli/rendertron
......@@ -10,24 +10,17 @@ map $http_user_agent$http2 $version {
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/donate.techcultivation.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/donate.techcultivation.org/privkey.pem;
include /etc/nginx/snippets/ssl-configuration.conf;
include /etc/nginx/snippets/sanitize-logs-per-server.conf;
server_name donate.techcultivation.org;
listen 80;
listen [::]:80;
# set server root to correct build
root /var/www/donate/$version;
# resolver for external domain lookups
resolver 8.8.8.8;
resolver {{ default .Env.RESOLVER "8.8.8.8" }};
# url of prerender service
set $rendertron "https://render-tron.appspot.com/render/";
set $rendertron "{{ default .Env.RENDERTRON_URL "https://render-tron.appspot.com/render/" }}";
# detect crawlers to serve a prerendered version
set $prerender 0;
......@@ -38,7 +31,7 @@ server {
# serve settings file
location /settings.json {
default_type application/json;
return 200 '{"api_url":"https://sandbox.api.sangha.techcultivation.org/v1"}';
return 200 '{"api_url":"{{ .Env.API_URL }}"}';
}
# serve service worker without cache headers
......@@ -66,7 +59,7 @@ server {
add_header X-Version $version;
# preconnect to api to save dns lookup and tls handshake time
add_header Link "<https://sandbox.api.sangha.techcultivation.org>; rel=preconnect; crossorigin";
add_header Link "<{{ .Env.API_URL }}>; rel=preconnect; crossorigin";
try_files $uri /index.html;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment