chore(): Building blog container for deployment
All checks were successful
continuous-integration/drone Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
Elia el Lazkani 2023-07-01 17:47:58 +02:00
parent 4a1580f113
commit e28a8c9d35
3 changed files with 48 additions and 30 deletions

View file

@ -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

5
Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM nginxinc/nginx-unprivileged:alpine
MAINTAINER Elia el Lazkani <elia@lazkani.io>
COPY public/ /usr/share/nginx/html/blog/
COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template

View file

@ -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;