From fdf1bc7421ef5ee56f9ef86be02088d34b9b6990 Mon Sep 17 00:00:00 2001 From: Simon C Date: Mon, 5 Dec 2022 15:02:52 +0100 Subject: [PATCH] feat: Add drone deploy --- .dockerignore | 4 -- .drone.yml | 135 +++++++++++++++++++++++++++++++++++ .env | 4 -- Dockerfile | 4 -- config/production/config.yml | 6 ++ config/staging/config.yml | 6 ++ docker-compose.prod.yml | 37 ---------- docker-compose.staging.yml | 19 ----- 8 files changed, 147 insertions(+), 68 deletions(-) delete mode 100644 .dockerignore create mode 100644 .drone.yml delete mode 100644 .env delete mode 100644 Dockerfile delete mode 100644 docker-compose.prod.yml delete mode 100644 docker-compose.staging.yml diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index f205c0b..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything -** - -!public diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..0cbd291 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,135 @@ +--- +# drone encrypt weko/weko.io $AWS_ACCESS_KEY_ID +kind: secret +name: STAGING_AWS_ACCESS_KEY_ID +data: WtVy8Op//nxf80WqKrVBUNucUohSNdfb+a6xBheoTJSktMo1R+MVj6vSsnyzRfeIjEX6oKBf + +--- +# drone encrypt weko/weko.io $AWS_SECRET_ACCESS_KEY +kind: secret +name: STAGING_AWS_SECRET_ACCESS_KEY +data: rrpzP1MZMKywkN1OppC9UaeLR1Zaa+Z9weQrduwUWX7YdSdwOKjxoYYRncV9leU8r9NGnJlIBtJaRA2I+FXPg/7q4ZhppAscDfcNxe1sug75Ni3exvYXeC0pbsU= + +--- +# drone encrypt weko/weko.io $AWS_ACCESS_KEY_ID +kind: secret +name: PRODUCTION_AWS_ACCESS_KEY_ID +data: hnpqmMR4M/j7dptGaUYX/OK/5zHRn2wsnorAwcakt76cl4AP0+so0rSqYcdVA05K8ER4PAkO + +--- +# drone encrypt weko/weko.io $AWS_SECRET_ACCESS_KEY +kind: secret +name: PRODUCTION_AWS_SECRET_ACCESS_KEY +data: NeDUFPKQazc+G7tILfKy4iNTildFBV3oPPn93NyIpu88xtQevk+Crg7km0z0yLevyTU//fkZ6fA9xw3bqWz7raSihzYn7V5TmStS57sykSglxWr0uPXkMazEKhg= + +--- +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 + volumes: + - name: hugo-theme-lowtech_node_modules + path: /drone/src/themes/hugo-theme-lowtech/node_modules + commands: + - (cd themes/hugo-theme-lowtech && npm i) + +- name: build website + image: klakegg/hugo:0.101.0-ext-debian-ci + commands: + - hugo --minify --environment production + +- name: typo + image: node:current-alpine + volumes: + - name: hugo-theme-lowtech_node_modules + path: /drone/src/themes/hugo-theme-lowtech/node_modules + commands: + - node themes/hugo-theme-lowtech/scripts/typo + +- name: deploy + image: klakegg/hugo:0.101.0-ext-debian-ci + environment: + AWS_ACCESS_KEY_ID: + from_secret: PRODUCTION_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: PRODUCTION_AWS_SECRET_ACCESS_KEY + commands: + - hugo deploy --environment production + +trigger: + event: + - push + branch: + - main + +volumes: +- name: hugo-theme-lowtech_node_modules + host: + path: /tmp/drone/cache/resilien/resilien_fr/themes/hugo-theme-lowtech + +--- +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 + volumes: + - name: hugo-theme-lowtech_node_modules + path: /drone/src/themes/hugo-theme-lowtech/node_modules + commands: + - (cd themes/hugo-theme-lowtech && npm i) + +- name: build website + image: klakegg/hugo:0.101.0-ext-debian-ci + commands: + - hugo --minify --buildDrafts --buildFuture --environment staging + +- name: typo + image: node:current-alpine + volumes: + - name: hugo-theme-lowtech_node_modules + path: /drone/src/themes/hugo-theme-lowtech/node_modules + commands: + - node themes/hugo-theme-lowtech/scripts/typo + +- name: deploy + image: klakegg/hugo:0.101.0-ext-debian-ci + environment: + AWS_ACCESS_KEY_ID: + from_secret: STAGING_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: STAGING_AWS_SECRET_ACCESS_KEY + commands: + - hugo deploy --environment staging + +trigger: + event: + - push + +volumes: +- name: hugo-theme-lowtech_node_modules + host: + path: /tmp/drone/cache/resilien/resilien_fr/themes/hugo-theme-lowtech diff --git a/.env b/.env deleted file mode 100644 index ea030cf..0000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -DOCKER_CONTEXT=vert.weko.resilien -NAME=vert.weko.resilien -URL=weko.io -STATS_CONTAINER=weko-stats diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 322c3a4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM registry.weko.io/nginx-lowtech:0.1.0 - -# Copie des sources du site -COPY public /usr/share/nginx/html diff --git a/config/production/config.yml b/config/production/config.yml index b0d194b..dd8fdbf 100644 --- a/config/production/config.yml +++ b/config/production/config.yml @@ -1 +1,7 @@ baseURL: https://weko.io/ + +deployment: + targets: + - name: production + URL: >- + s3://weko.io?endpoint=http://10.20.20.10:3900&disableSSL=true&s3ForcePathStyle=true®ion=garage diff --git a/config/staging/config.yml b/config/staging/config.yml index c601177..a8a3552 100644 --- a/config/staging/config.yml +++ b/config/staging/config.yml @@ -1 +1,7 @@ baseURL: https://staging.weko.io/ + +deployment: + targets: + - name: staging + URL: >- + s3://staging.weko.io?endpoint=http://10.20.20.10:3900&disableSSL=true&s3ForcePathStyle=true®ion=garage diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index eba1617..0000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,37 +0,0 @@ -version: "3.8" - -volumes: - weko-log: - name: weko-log - weko-stats: - name: weko-stats - -services: - weko-prod: - container_name: weko-prod - build: . - restart: always - labels: - traefik.enable: "true" - traefik.http.routers.weko.rule: "Host(`${URL}`)" - traefik.http.routers.weko.entrypoints: "web" - volumes: - - weko-log:/var/log/nginx - - weko-stats:/usr/share/nginx/html/stats - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - - weko-stats: - container_name: weko-stats - image: registry.weko.io/goaccess:1.5.1 - restart: always - volumes: - - weko-log:/var/log/nginx - - weko-stats:/usr/share/nginx/html/stats - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - -networks: - default: - external: - name: traefik diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml deleted file mode 100644 index a34baf4..0000000 --- a/docker-compose.staging.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: "3.8" - -networks: - default: - external: - name: traefik - -services: - weko-staging: - container_name: weko-staging - build: . - restart: always - labels: - traefik.enable: "true" - traefik.http.routers.weko-staging.rule: "Host(`staging.${URL}`)" - traefik.http.routers.weko-staging.entrypoints: "web" - volumes: - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro