ci: add a deploy step using docker-compose
All checks were successful
continuous-integration/drone/push Build is passing

docs image is built JIT from Dockerfile.
the logic for the compose file is based on the one used in
https://git.dotya.ml/dotya.ml/homepage yet the traefik part was not
used.
This commit is contained in:
surtur 2021-07-24 14:45:23 +02:00
parent c0c05e1aee
commit 4bc2650892
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 124 additions and 0 deletions

View File

@ -44,6 +44,83 @@ steps:
- hugo version
- hugo --gc=true --minify
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
trigger:
branch:
- master
event:
exclude: [pull_request, tag]
environment:
# ref: https://www.docker.com/blog/faster-builds-in-compose-thanks-to-buildkit-support/
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
node:
r: main
depends_on:
- build
steps:
- name: hugo-extended
pull: if-not-exists
image: immawanderer/fedora-hugo:latest
commands:
- git submodule init
- git submodule update
- hugo version
- hugo --gc=true --minify
- name: rm-intermediate
pull: if-not-exists
image: immawanderer/fedora-hugo:latest
depends_on:
- hugo-extended
commands:
- rm -rf ./public
- name: build
pull: always
image: tmaier/docker-compose:latest
depends_on:
- rm-intermediate
volumes:
- name: s
path: /var/run/docker.sock
commands:
- docker-compose build --no-cache
when:
branch: master
status: success
- name: deploy
pull: always
image: tmaier/docker-compose:latest
depends_on:
- build
volumes:
- name: s
path: /var/run/docker.sock
commands:
- docker-compose up -d --remove-orphans
when:
branch: master
status: success
volumes:
- name: s
host:
path: /var/run/docker.sock
---
kind: pipeline
name: notifications

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM immawanderer/fedora-hugo:latest AS hugobuild
RUN mkdir -pv /docs
COPY . /docs
WORKDIR /docs
RUN git submodule init \
&& git submodule update --recursive \
&& hugo version
RUN hugo --minify --gc=true
# WORKDIR /
FROM nginx:mainline-alpine
# COPY --from=hugobuild /home/$(whoami)/public/ /usr/share/nginx/html
COPY --from=hugobuild /docs/public/ /usr/share/nginx/html
# tripple slash reference
# https://stackoverflow.com/questions/5190966/using-sed-to-insert-tabs/5191165#5191165
RUN sed -i -e 's/^worker_processes auto;/worker_processes auto;/'\
-e "/^events {$/ a \\\tmulti_accept on;\n\tuse epoll;"\
-e "/^http {$/ a \\\tserver_tokens off;\n\tetag off;\n"\
-e 's/#tcp_nopush/tcp_nopush/'\
-e "/tcp_nopush/ a \\\ttcp_nodelay on;"\
-e "s/^ */$(printf '\t')/"\
/etc/nginx/nginx.conf

21
docker-compose.yml Normal file
View File

@ -0,0 +1,21 @@
version: '3'
services:
docs:
build:
context: .
image: docs
networks:
- default
restart: always
ports:
- 127.0.0.1:1315:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
logging:
driver: json-file
options:
max-size: "5m"
max-file: "5"
networks:
default: