docker-compose deployment (#18)
All checks were successful
continuous-integration/drone/push Build is passing

refactor: .drone.yml + don't run on {push,PR}

add: docker-compose-build pipeline

* general refactoring of .drone.yml

fix: incorrect dependency

* add: don't run img pull on PR

refactor: update .drone.yml logic

chore: adding docker-compose.yml

* it's in fact going to be docker-compose deployment

add: Dockerfile + update baseUrl

* also enhance footer partial that cries when a ref goes missing (such
  as when a branch is merged)

Co-authored-by: surtur <a_mirre@utb.cz>
Reviewed-on: #18
Co-Authored-By: wanderer <wanderer@noreply.git.dotya.ml>
Co-Committed-By: wanderer <wanderer@noreply.git.dotya.ml>
This commit is contained in:
wanderer 2020-10-03 21:00:19 +02:00
parent 112e77ce67
commit 41099802c2
Signed by: Gitea
GPG Key ID: 0DD13DBC6B5433D3
5 changed files with 141 additions and 17 deletions

View File

@ -6,6 +6,10 @@ name: pull
clone:
disable: true
trigger:
event:
exclude: [push, pull_request]
steps:
- name: fedora-hugo
pull: always
@ -30,6 +34,10 @@ platform:
os: linux
arch: amd64
trigger:
branch: [master, testing]
event: pull_request
depends_on:
- pull
@ -37,23 +45,48 @@ steps:
- name: hugo-extended
pull: if-not-exists
image: immawanderer/fedora-hugo:latest
when:
branch:
- master
event:
- push
- pull_request
commands:
- git submodule init
- git submodule update
- hugo version
- hugo --gc=true --minify
---
kind: pipeline
type: docker
name: docker-compose-build
platform:
os: linux
arch: amd64
trigger:
branch: master
event: pull_request
depends_on:
- build
steps:
- name: build
pull: always
image: tmaier/docker-compose:latest
volumes:
- name: s
path: /var/run/docker.sock
commands:
- docker-compose build
volumes:
- name: s
host:
path: /var/run/docker.sock
---
kind: pipeline
type: docker
name: deploy
name: deploy-staging
platform:
os: linux
@ -61,12 +94,9 @@ platform:
trigger:
branch:
- master
- testing
event:
exclude:
- pull_request
- tag
exclude: [pull_request, tag]
depends_on:
- build
@ -88,7 +118,7 @@ steps:
status:
- success
branch:
- master
- testing
depends_on:
- hugo-extended
environment:
@ -104,6 +134,63 @@ steps:
- rsync -av --delete --chown $OL public/ $OL@dotya.ml:$OL_D
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
trigger:
branch:
- master
event:
exclude: [pull_request, tag]
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 stop homepage || true
- docker-compose up --build -d
when:
branch: master
status: success
volumes:
- name: s
host:
path: /var/run/docker.sock
---
kind: pipeline
name: notifications
@ -118,7 +205,7 @@ clone:
trigger:
branch:
- master
- "*"
- testing
event:
- push
- tag
@ -126,8 +213,7 @@ trigger:
- success
- failure
depends_on:
- deploy
depends_on: [deploy, deploy-staging]
steps:
- name: discord

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM immawanderer/fedora-hugo:latest
RUN mkdir -pv /homepage
COPY . /homepage
WORKDIR /homepage
RUN git submodule init \
&& git submodule update --recursive \
&& hugo version
RUN hugo --minify --gc=true
WORKDIR /
FROM nginx
COPY --from=0 /homepage/public/ /usr/share/nginx/html

View File

@ -1,4 +1,4 @@
baseurl = "https://dotya.ml"
baseurl = "/"
languageCode = "en-us"
defaultContentLanguage = "en"
theme = "hermit"

23
docker-compose.yml Normal file
View File

@ -0,0 +1,23 @@
version: '3'
services:
homepage:
container_name: homepage
build:
context: .
image: homepage
networks:
- default
restart: unless-stopped
ports:
- "127.0.0.1:1314:80"
environment:
- ENABLE_IPV6=true
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
labels:
"homepage": "true"
logging:
driver: json-file
options:
max-size: "5m"
max-file: "5"

View File

@ -1,3 +1,3 @@
<footer id="site-footer" class="section-inner thin animated fadeIn faster">
<p>&copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a>{{ .Site.Params.footerCopyright | safeHTML }} &#183 <a href="https://git.dotya.ml/dotya.ml/homepage" title="source code" target="_blank" rel="noopener">source</a> &#183 <a href="https://status.dotya.ml" title="service status" target="_blank" rel="noopener">status</a><br/><a href="https://git.dotya.ml/dotya.ml/homepage/commit/{{ .GitInfo.Hash }}" target="_blank" rel="noopener">commit {{ .GitInfo.AbbreviatedHash }}</a></p>
<p>&copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a>{{ .Site.Params.footerCopyright | safeHTML }} &#183 <a href="https://git.dotya.ml/dotya.ml/homepage" title="source code" target="_blank" rel="noopener">source</a> &#183 <a href="https://status.dotya.ml" title="service status" target="_blank" rel="noopener">status</a>{{if .Site.Params.enableGitInfo}}<br/><a href="https://git.dotya.ml/dotya.ml/homepage/commit/{{ .GitInfo.Hash }}" target="_blank" rel="noopener">commit {{ .GitInfo.AbbreviatedHash }}</a>{{end}}</p>
</footer>