From 6c9efab92bcb5743ea7c221da51ec18d87ff9fd3 Mon Sep 17 00:00:00 2001 From: Simon C Date: Tue, 1 Feb 2022 11:10:24 +0100 Subject: [PATCH] feat: Add auto build website with Drone --- .drone.yml | 117 +++++++++++++++++++++++++++++++++++++ docker-compose.prod.yml | 2 + docker-compose.staging.yml | 2 + 3 files changed, 121 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..8130050 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,117 @@ +--- + # drone encrypt resilien/resilien.fr $REGISTRY_PASSWORD +kind: secret +name: REGISTRY_PASSWORD +data: dYAxgJzu+Ic48OIWSFSy1fIG/Z9UUb7ErEyN+3KyI3DaVl1HKWIjdhd6HQZNcgjyKqxZh+smR7CeklVTO2cJhAfQfXIu8ENfGW1QEiFM + +--- +# drone encrypt resilien/resilien.fr $REGISTRY_USER +kind: secret +name: REGISTRY_USER +data: Y/LGloHcxShJGmqXaGvFJYLSCDbG7wWZap8oywddPdJfcw== + +--- +# drone encrypt resilien/resilien.fr "{\"auths\":{\"https://registry.weko.io\":{\"auth\":\"$(echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64)\",\"email\":\"$REGISTRY_USER\"}}}" +kind: secret +name: REGISTRY_CONFIG +data: ICKt0HnBLKDrCNUH1xJnOKCwOMn/R+xMqtO8AxQ8ZorJO/J1O3hUFx3gYH6uKe3y3qa73zGPjSHnTGFv43eGBS0K8L0qQtXdLqIKTOQiIMK9CENN+w8uULCKSls01XHv7zY0bGR5FjmniXCLNYHiWHnJOi8xbAkDorhy6GwhBBpsumsZ6uzA5I0NfHTs+gplvQh6H+6Dmh03ygx39pMfE+P1F2D5VS9OiieS + +--- +kind: pipeline +type: docker +name: prod + +platform: + os: linux + arch: arm64 + +steps: +- name: install submodule + image: drone/git + commands: + - git submodule update --init + +- name: install npm + image: node:current-alpine + commands: + - (cd themes/hugo-theme-lowtech && npm i) + +- name: build website + image: jakejarvis/hugo-extended + commands: + - hugo --minify --environment production + +- name: typo + image: node:current-alpine + commands: + - node themes/hugo-theme-lowtech/scripts/typo + +- name: build and push docker image on registry + image: plugins/docker + settings: + username: + from_secret: REGISTRY_USER + password: + from_secret: REGISTRY_PASSWORD + repo: registry.weko.io/resilien_fr + registry: registry.weko.io + tags: + - latest + +image_pull_secrets: +- REGISTRY_CONFIG + +trigger: + event: + - push + branch: + - main + +--- +kind: pipeline +type: docker +name: staging + +platform: + os: linux + arch: arm64 + +steps: +- name: install submodule + image: drone/git + commands: + - git submodule update --init + +- name: install npm + image: node:current-alpine + commands: + - (cd themes/hugo-theme-lowtech && npm i) + +- name: build website + image: jakejarvis/hugo-extended + commands: + - hugo --minify --buildDrafts --buildFuture --environment staging + +- name: typo + image: node:current-alpine + commands: + - node themes/hugo-theme-lowtech/scripts/typo + +- name: push docker image on registry + image: plugins/docker + settings: + username: + from_secret: REGISTRY_USER + password: + from_secret: REGISTRY_PASSWORD + repo: registry.weko.io/resilien_fr + registry: registry.weko.io + tags: + - staging + +image_pull_secrets: +- REGISTRY_CONFIG + +trigger: + event: + - push diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 463e8c7..56ed7bf 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -10,11 +10,13 @@ services: resilien-prod: container_name: resilien-prod build: . + image: registry.weko.io/resilien_fr:prod restart: always labels: traefik.enable: "true" traefik.http.routers.resilien.rule: "Host(`${URL}`)" traefik.http.routers.resilien.entrypoints: "web" + com.centurylinklabs.watchtower.enable: true volumes: - resilien-log:/var/log/nginx - resilien-stats:/usr/share/nginx/html/stats diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index 507754a..d52a9a2 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -8,11 +8,13 @@ services: resilien-staging: container_name: resilien-staging build: . + image: registry.weko.io/resilien_fr:staging restart: always labels: traefik.enable: "true" traefik.http.routers.resilien-staging.rule: "Host(`staging.${URL}`)" traefik.http.routers.resilien-staging.entrypoints: "web" + com.centurylinklabs.watchtower.enable: true volumes: - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro