Update .woodpecker.yml
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
colin 2023-12-13 20:30:38 +00:00 committed by Colin
parent 8fa11d79d3
commit 10e1ff8e5e
10 changed files with 320 additions and 6 deletions

View File

@ -1,6 +0,0 @@
version: "3.9"
services:
well-known:
build:
context: docker/vault
image: git.nixc.us/colin/vault:production

156
.woodpecker.yml Normal file
View File

@ -0,0 +1,156 @@
labels:
hostname: "macmini7"
clone:
git:
image: woodpeckerci/plugin-git
settings:
partial: false
depth: 1
steps:
# Build Step for staging Branch
build-staging:
name: build-staging
image: woodpeckerci/plugin-docker-buildx
secrets: [REGISTRY_USER, REGISTRY_PASSWORD]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- echo "Building application for staging branch"
- echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us
- echo compose build
- docker compose -f docker-compose.staging.yml build
when:
- branch: main
- event: push
- path:
include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]
deploy-new:
name: deploy-new
when:
- branch: main
- path:
include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]
image: woodpeckerci/plugin-docker-buildx
secrets: [REGISTRY_USER, REGISTRY_PASSWORD]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us
- echo compose push
- docker compose -f docker-compose.staging.yml push
- docker stack deploy --with-registry-auth -c ./stack.staging.yml $${CI_REPO_NAME}-staging
# run-tests:
# name: run-tests-in-container
# image: docker
# commands:
# - docker-compose -f docker-compose.test.yml up --abort-on-container-exit
# - docker-compose -f docker-compose.test.yml down
# when:
# branch: main
# event: push
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# Wait for Deploy to Complete
wait-for-deploy-staging:
name: wait-for-deploy-staging
image: woodpeckerci/plugin-git
commands:
- echo "Waiting for staging deploy step to complete rollout."
- sleep 20
when:
- branch: main
- event: push
# # Run Automated Tests on staging Branch
# test-staging:
# name: run-tests-staging
# image: git.nixc.us/colin/playwright:latest
# secrets: [ base_url ]
# when:
# - branch: main
# - event: push
# - path:
# include: [ 'tests/', 'src/','docker-compose.staging.yml', 'docker-compose.production.yml', '*.tests.ts' ] # Specify paths relevant to tests
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock:ro
cleanup-staging:
name: cleanup-staging
when:
- branch: main
- path:
include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]
image: woodpeckerci/plugin-docker-buildx
secrets: [REGISTRY_USER, REGISTRY_PASSWORD]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
# - docker stack rm $${CI_REPO_NAME}-staging
## added fault tolerance for docker stack rm
- for i in {1..5}; do docker stack rm ${CI_REPO_NAME}-staging && break || sleep 10; done
- docker compose -f docker-compose.staging.yml down
- docker compose -f docker-compose.staging.yml rm -f
# Build Step for staging Branch
build-build-push-production:
name: build-build-push-production
image: woodpeckerci/plugin-docker-buildx
secrets: [REGISTRY_USER, REGISTRY_PASSWORD]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- echo "Building application for staging branch"
- echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us
- echo compose build
- docker compose -f docker-compose.production.yml build
- docker compose -f docker-compose.production.yml push
when:
- branch: production
- event: push
- path:
include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]
# Deploy to Production Branch
deploy-production:
name: deploy-production
image: woodpeckerci/plugin-docker-buildx
secrets: [REGISTRY_USER, REGISTRY_PASSWORD]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us
- docker stack deploy --with-registry-auth -c ./stack.production.yml $${CI_REPO_NAME}
when:
- branch: production
- event: push
# - path:
# include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]
# # Wait for Deploy to Complete
# wait-for-deploy-production:
# name: wait-for-deploy-production
# image: woodpeckerci/plugin-git
# commands:
# - echo "Waiting for deploy step to complete rollout."
# - sleep 60
# when:
# - branch: production
# - event: push
# # Run Post-Deployment Smoke Tests
# post-deploy-smoke-tests-git-nixc-us:
# name: run-post-deploy-smoke-tests-git-nixc-us
# image: git.nixc.us/colin/playwright:latest
# # secrets: [TEST_USER, TEST_PASSWORD]
# environment:
# - BASE_URL=https://git.nixc.us
# when:
# - branch: production
# - event: push
# # - path:
# # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ]

1
README.md Normal file
View File

@ -0,0 +1 @@
<!-- #build10 -->

View File

@ -0,0 +1,10 @@
version: "3.9"
services:
redis:
build:
context: docker/redis
image: git.nixc.us/colin/haste:redis-production
haste:
build:
context: docker/haste
image: git.nixc.us/colin/haste:haste-production

View File

@ -0,0 +1,10 @@
version: "3.9"
services:
redis:
build:
context: docker/redis
image: git.nixc.us/colin/haste:redis-staging
haste:
build:
context: docker/haste
image: git.nixc.us/colin/haste:haste-staging

18
docker-compose.test.yml Normal file
View File

@ -0,0 +1,18 @@
version: '3'
services:
app:
image: git.nixc.us/colin/haste:haste-staging
environment:
TEST_MODE: "true"
STORAGE_TYPE: "redis"
STORAGE_HOST: "redis"
depends_on:
- redis
networks:
- haste-test
redis:
image: redis
networks:
- haste-test
networks:
haste-test:

13
docker/haste/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM node:6-alpine as builder
RUN apk add --no-cache git
RUN git clone https://git.nixc.us/Nixius/hastebin.git /app
WORKDIR /app
RUN npm install --production
RUN chmod +x app.sh
FROM node:6-alpine
WORKDIR /app
COPY --from=builder /app .
RUN npm install --production
RUN npm install mocha
CMD ["/app/app.sh"]

1
docker/redis/Dockerfile Normal file
View File

@ -0,0 +1 @@
FROM redis:6-alpine

47
stack.production.yml Normal file
View File

@ -0,0 +1,47 @@
version: '3.8'
services:
redis:
image: git.nixc.us/colin/haste:redis-production
# volumes:
# - redis_data:/data
networks:
- default
deploy:
# placement:
# constraints:
# - node.hostname == macmini3
replicas: 1
restart_policy:
condition: on-failure
haste:
image: git.nixc.us/colin/haste:haste-production
# volumes:
# - public_system:/haste/public/system
networks:
- traefik
- default
deploy:
# placement:
# constraints:
# - node.hostname == macmini3
labels:
us.nixc.autodeploy: "true"
traefik.enable: "true"
traefik.http.routers.production-haste_haste.rule: "Host(`haste.nixc.us`)"
traefik.http.routers.production-haste_haste.entrypoints: "websecure"
traefik.http.routers.production-haste_haste.tls: "true"
traefik.http.routers.production-haste_haste.tls.certresolver: "letsencryptresolver"
traefik.http.routers.production-haste_haste.service: "production-haste_haste"
traefik.http.services.production-haste_haste.loadbalancer.server.port: "7777"
traefik.docker.network: "traefik"
replicas: 1
restart_policy:
condition: on-failure
networks:
traefik:
external: true
default:
driver: overlay

64
stack.staging.yml Normal file
View File

@ -0,0 +1,64 @@
version: '3.8'
services:
redis:
image: git.nixc.us/colin/haste:redis-staging
# volumes:
# - redis_data:/data
networks:
- default
deploy:
# placement:
# constraints:
# - node.hostname == macmini3
replicas: 1
restart_policy:
condition: on-failure
haste:
image: git.nixc.us/colin/haste:haste-staging
# volumes:
# - public_system:/haste/public/system
networks:
- traefik
- default
environment:
HOST: "0.0.0.0"
PORT: "7777"
KEY_LENGTH: "10"
MAX_LENGTH: "400000"
STATIC_MAX_AGE: "7776000"
RECOMPRESS_STATIC_ASSETS: "true"
LOGGING_LEVEL: "verbose"
LOGGING_TYPE: "Console"
LOGGING_COLORIZE: "false"
KEY_GENERATOR_TYPE: "phonetic"
STORAGE_TYPE: "redis"
STORAGE_PATH: "./data"
STORAGE_HOST: "haste-staging_redis"
STORAGE_PORT: "6379"
STORAGE_DB: "2"
STORAGE_EXPIRE: "2592000"
deploy:
# placement:
# constraints:
# - node.hostname == macmini3
labels:
us.nixc.autodeploy: "true"
traefik.enable: "true"
traefik.http.routers.staging-haste_haste.rule: "Host(`staging.haste.nixc.us`)"
traefik.http.routers.staging-haste_haste.entrypoints: "websecure"
traefik.http.routers.staging-haste_haste.tls: "true"
traefik.http.routers.staging-haste_haste.tls.certresolver: "letsencryptresolver"
traefik.http.routers.staging-haste_haste.service: "staging-haste_haste"
traefik.http.services.staging-haste_haste.loadbalancer.server.port: "7777"
traefik.docker.network: "traefik"
replicas: 1
restart_policy:
condition: on-failure
networks:
traefik:
external: true
default:
driver: overlay