From e28a8c9d35d6a7c4bb4551d0c094a4892434b63e Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 1 Jul 2023 17:47:58 +0200 Subject: [PATCH] chore(): Building blog container for deployment --- .drone.yml | 69 ++++++++++++++++++++++--------------- Dockerfile | 5 +++ nginx/default.conf.template | 4 +-- 3 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 Dockerfile diff --git a/.drone.yml b/.drone.yml index a41c88f..35baca6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,44 +6,57 @@ clone: depth: 1 steps: -- name: submodules +- name: update-submodules image: alpine/git commands: - git submodule update --init --recursive -- name: build +- name: generate-blog image: plugins/hugo settings: hugo_version: 0.84.4 validate: true pull: always -- name: deploy - image: docker:dind - volumes: - - name: docker-socket - path: /var/run/docker.sock - - name: blog-path - path: /blog/ - environment: - UID: - from_secret: uid - GID: - from_secret: gid +- name: clean-up-images + image: alpine commands: - - mv nginx/ public/ - rm -rf public/images/* - - chown -R "$UID":"$GID" public/ - - mv public/ "/blog/${DRONE_COMMIT}" - - cd /blog/ - - rm -f blog.lazkani.io - - ln -s "${DRONE_COMMIT}" blog.lazkani.io - - docker restart nginx -volumes: - - name: docker-socket - host: - path: /var/run/docker.sock - - name: blog-path - host: - path: /mnt/blog/ +- name: test-build-container + image: plugins/docker + settings: + registry: scm.project42.io + username: + from_secret: registry_username + password: + from_secret: registry_password + repo: scm.project42.io/elia/blog + dry_run: true + squash: true + tags: + - "${DRONE_COMMIT_SHA:0:8}" + when: + event: + exclude: + - tag + +- name: build-container + image: plugins/docker + settings: + registry: scm.project42.io + username: + from_secret: registry_username + password: + from_secret: registry_password + repo: scm.project42.io/elia/blog + dry_run: false + squash: true + tags: + - latest + - "${DRONE_COMMIT_SHA:0:8}" + when: + event: + - promote + target: + - production diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5aadf20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM nginxinc/nginx-unprivileged:alpine +MAINTAINER Elia el Lazkani + +COPY public/ /usr/share/nginx/html/blog/ +COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template diff --git a/nginx/default.conf.template b/nginx/default.conf.template index f43772d..cadacda 100644 --- a/nginx/default.conf.template +++ b/nginx/default.conf.template @@ -1,9 +1,9 @@ server { - listen ${NGINX_BLOG_PORT}; + listen ${NGINX_PORT}; server_name localhost; - root /usr/share/nginx/html/${NGINX_BLOG_HOST}; + root /usr/share/nginx/html/blog; error_page 404 /not-found/index.html; error_page 403 /forbidden/index.html;