From 62095aa378de2219012f0289a2b8a1bcb095bdd0 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 16:40:36 +0200 Subject: [PATCH 1/6] add: Dockerfile + update baseUrl * also enhance footer partial that cries when a ref goes missing (such as when a branch is merged) --- Dockerfile | 15 +++++++++++++++ config.toml | 2 +- layouts/partials/footer.html | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e874692 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/config.toml b/config.toml index 63c29be..5e15c1d 100644 --- a/config.toml +++ b/config.toml @@ -1,4 +1,4 @@ -baseurl = "https://dotya.ml" +baseurl = "/" languageCode = "en-us" defaultContentLanguage = "en" theme = "hermit" diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index e3a1474..90069af 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,3 +1,3 @@ -- 2.47.0 From f449013be83cea876e1e8f783f4f70142617fd40 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 19:56:20 +0200 Subject: [PATCH 2/6] chore: adding docker-compose.yml * it's in fact going to be docker-compose deployment --- docker-compose.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..efb8091 --- /dev/null +++ b/docker-compose.yml @@ -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" -- 2.47.0 From bdeddff68c93e397c4ba9aacb46ac43b566da46c Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 20:29:34 +0200 Subject: [PATCH 3/6] refactor: update .drone.yml logic --- .drone.yml | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index cd600fc..1b37a5e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,6 +30,12 @@ platform: os: linux arch: amd64 +trigger: + branch: + - master + event: + - pull_request + depends_on: - pull @@ -37,18 +43,47 @@ 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-build + +platform: + os: linux + arch: amd64 + +trigger: + branch: + - master + event: + - pull_request + +depends_on: +- build + +steps: +- name: docker-build + pull: always + image: tmaier/docker-compose:latest + depends_on: + - hugo-extended + volumes: + - name: s + path: /var/run/docker.sock + commands: + - docker-compose build + +volumes: +- name: s + host: + path: /var/run/docker.sock + --- kind: pipeline @@ -69,7 +104,7 @@ trigger: - tag depends_on: -- build +- docker-build steps: - name: hugo-extended @@ -118,7 +153,7 @@ clone: trigger: branch: - master - - "*" + - testing event: - push - tag -- 2.47.0 From 68fe603c047aded767adf97644d37d49e1cfe829 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 20:32:23 +0200 Subject: [PATCH 4/6] fix: incorrect dependency * add: don't run img pull on PR --- .drone.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1b37a5e..5287e70 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,11 @@ name: pull clone: disable: true +trigger: + event: + exclude: + - pull_request + steps: - name: fedora-hugo pull: always @@ -71,8 +76,6 @@ steps: - name: docker-build pull: always image: tmaier/docker-compose:latest - depends_on: - - hugo-extended volumes: - name: s path: /var/run/docker.sock -- 2.47.0 From 4896480b0091e2619bfa455801856e4438aa39d4 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 20:50:00 +0200 Subject: [PATCH 5/6] add: docker-compose-build pipeline * general refactoring of .drone.yml --- .drone.yml | 87 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5287e70..60cfc76 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,10 +36,8 @@ platform: arch: amd64 trigger: - branch: - - master - event: - - pull_request + branch: [master, testing] + event: pull_request depends_on: - pull @@ -57,23 +55,21 @@ steps: --- kind: pipeline type: docker -name: docker-build +name: docker-compose-build platform: os: linux arch: amd64 trigger: - branch: - - master - event: - - pull_request + branch: master + event: pull_request depends_on: - build steps: -- name: docker-build +- name: build pull: always image: tmaier/docker-compose:latest volumes: @@ -91,7 +87,7 @@ volumes: --- kind: pipeline type: docker -name: deploy +name: deploy-staging platform: os: linux @@ -99,15 +95,12 @@ platform: trigger: branch: - - master - testing event: - exclude: - - pull_request - - tag + exclude: [pull_request, tag] depends_on: -- docker-build +- build steps: - name: hugo-extended @@ -126,7 +119,7 @@ steps: status: - success branch: - - master + - testing depends_on: - hugo-extended environment: @@ -142,6 +135,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 @@ -164,8 +214,7 @@ trigger: - success - failure -depends_on: -- deploy +depends_on: [deploy, deploy-staging] steps: - name: discord -- 2.47.0 From 6f0e5a649c4cfe63647a2a4974f65d7999839112 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 3 Oct 2020 20:52:51 +0200 Subject: [PATCH 6/6] refactor: .drone.yml + don't run on {push,PR} --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 60cfc76..100f5f1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,8 +8,7 @@ clone: trigger: event: - exclude: - - pull_request + exclude: [push, pull_request] steps: - name: fedora-hugo -- 2.47.0