From 2415eb579b391b29d8cc4d8cda645a58c4bbf4a5 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Fri, 22 Nov 2019 20:51:05 -0500 Subject: [PATCH 1/6] Gitlab CI --- .gitlab-ci.yml | 20 ++++++++++++++++++++ pelicanconf.py | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..871ac9e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,20 @@ +image: "python:alpine" + +services: + - "instrumentisto/rsync-ssh" + +variables: + SITEURL: 'https://ant.sr/' + +before_script: + - pip3 install -r requirements.txt + +build: + stage: build + script: pelican content -o output -s pelicanconf.py + +deploy: + stage: deploy + script: + - chmod 600 "$DEPLOY_KEY" + - rsync -rv -e 'ssh -i "$DEPLOY_KEY" -o UserKnownHostsFile="$DEPLOY_KNOWN_HOSTS"' output "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH" diff --git a/pelicanconf.py b/pelicanconf.py index 686e249..75640fe 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # from __future__ import unicode_literals +import os + AUTHOR = 'Anton Sarukhanov' SITENAME = 'Anton Sarukhanov' SITESUBTITLE = 'Full-Stack Developer' -# SITEURL = 'https://ant.sr/' +SITEURL = os.environ.get('SITEURL') PLUGINS = ['advthumbnailer'] -- GitLab From 672528383f6ca09acfe6bd34dd6b93b2203c4482 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Fri, 22 Nov 2019 22:10:59 -0500 Subject: [PATCH 2/6] Use custom docker to build faster. --- .dockerignore | 2 ++ .gitlab-ci.yml | 9 +++------ Dockerfile | 8 ++++++++ requirements.txt | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..98253ac --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 871ac9e..86a2232 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,6 @@ -image: "python:alpine" - -services: - - "instrumentisto/rsync-ssh" +image: "antsar/antsr" variables: - SITEURL: 'https://ant.sr/' before_script: - pip3 install -r requirements.txt @@ -16,5 +12,6 @@ build: deploy: stage: deploy script: + - pelican content -o output -s pelicanconf.py - chmod 600 "$DEPLOY_KEY" - - rsync -rv -e 'ssh -i "$DEPLOY_KEY" -o UserKnownHostsFile="$DEPLOY_KNOWN_HOSTS"' output "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH" + - rsync -arv -e "ssh -i \"$DEPLOY_KEY\" -o UserKnownHostsFile=\"$DEPLOY_KNOWN_HOSTS\"" output/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..694e9ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM debian + +ADD requirements.txt /tmp/requirements.txt + +WORKDIR /tmp + +RUN apt-get update -qq && apt-get install -qq python3-dev python3-pip zlib1g-dev libjpeg-dev rsync openssh-client +RUN pip3 install -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 70ee8c9..93f8cfd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ +wheel pelican==3.6.3 Markdown==2.6.6 pelican-advthumbnailer==0.5.0 +piexif==1.1.3 +Pillow==5.0.0 -- GitLab From 582883fb1f065420e05c55e1c57e37db333b7c80 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Wed, 22 Apr 2020 22:34:08 -0400 Subject: [PATCH 3/6] WIP container --- .gitlab-ci.yml | 39 +++++++++++++++++++++++++-------------- Dockerfile | 9 ++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86a2232..49871c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,28 @@ -image: "antsar/antsr" +stages: + - build_content + - build_image -variables: - -before_script: - - pip3 install -r requirements.txt - -build: - stage: build - script: pelican content -o output -s pelicanconf.py - -deploy: - stage: deploy +build_content: + stage: build_content + image: python:3 script: + - pip install -r requirements.txt - pelican content -o output -s pelicanconf.py - - chmod 600 "$DEPLOY_KEY" - - rsync -arv -e "ssh -i \"$DEPLOY_KEY\" -o UserKnownHostsFile=\"$DEPLOY_KNOWN_HOSTS\"" output/ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH" + artifacts: + paths: + - output/ + +build_image: + stage: build_image + dependencies: + - build_content + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + only: + - tags diff --git a/Dockerfile b/Dockerfile index 694e9ec..2f9e9fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,3 @@ -FROM debian +FROM nginx:1.17 -ADD requirements.txt /tmp/requirements.txt - -WORKDIR /tmp - -RUN apt-get update -qq && apt-get install -qq python3-dev python3-pip zlib1g-dev libjpeg-dev rsync openssh-client -RUN pip3 install -r requirements.txt +COPY output /usr/share/nginx/html -- GitLab From ac1cc6e0cb9bf8006e36458573bcd8fe473fd43e Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Wed, 22 Apr 2020 22:49:29 -0400 Subject: [PATCH 4/6] docker needs output --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 98253ac..06311f0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ * +!output !requirements.txt -- GitLab From caacbe396620ebbd9038cc042bb4c1ea5aed9106 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Sun, 26 Apr 2020 14:40:28 -0400 Subject: [PATCH 5/6] WIP CI --- Dockerfile | 5 ++++- nginx.conf | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 2f9e9fe..46df403 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ FROM nginx:1.17 -COPY output /usr/share/nginx/html +RUN rm /etc/nginx/conf.d/default.conf + +COPY nginx.conf /etc/nginx/conf.d/ant.sr.conf +COPY output /opt/ant.sr/html diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4d50d1f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + location / { + root /opt/ant.sr/html; + error_page 404 = @files; + } + location @files { + root /opt/ant.sr/files; + error_page 404 = @urlshortener + } + location @urlshortener { + # TODO! + return 404; + } +} -- GitLab From 77d9b646e17ce9eccd55042a37a293e604648bc0 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Sun, 26 Apr 2020 14:47:23 -0400 Subject: [PATCH 6/6] WIP CI --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 06311f0..b5fec70 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ * !output +!nginx.conf !requirements.txt -- GitLab