diff --git a/.cursor/rules.json b/.cursor/rules.json index 8848517..78e495f 100644 --- a/.cursor/rules.json +++ b/.cursor/rules.json @@ -1,81 +1,85 @@ { - "version": 1, - "rules": [ - { - "pattern": "**/*", - "rule": "project-structure.mdc" - }, - { - "pattern": "**/docker/template/Dockerfile", - "rule": "dockerfiles.mdc" - }, - { - "pattern": "**/docker/template/Dockerfile.production", - "rule": "dockerfiles.mdc" - }, - { - "pattern": "**/docker-compose.dev.yml", - "rule": "docker-compose-files.mdc" - }, - { - "pattern": "**/docker-compose.staging.yml", - "rule": "docker-compose-files.mdc" - }, - { - "pattern": "**/docker-compose.production.yml", - "rule": "docker-compose-files.mdc" - }, - { - "pattern": "**/docker-compose.test.yml", - "rule": "docker-compose-files.mdc" - }, - { - "pattern": "**/stack.staging.yml", - "rule": "stack-files.mdc" - }, - { - "pattern": "**/stack.production.yml", - "rule": "stack-files.mdc" - }, - { - "pattern": "**/*.sh", - "rule": "scripts.mdc" - }, - { - "pattern": "**/build-test-run.sh", - "rule": "git-workflow.mdc" - }, - { - "pattern": "**/temp/**/*", - "rule": ["temp-directory.mdc", "gitkeep-handling.mdc"] - }, - { - "pattern": "**/.gitignore", - "rule": "gitignore.mdc" - }, - { - "pattern": "**/.git/**/*", - "rule": "git-workflow.mdc" - }, - { - "pattern": "**/docker/template/src/**/*", - "rule": ["source-code.mdc", "gitkeep-handling.mdc"] - }, - { - "pattern": "**/.gitkeep", - "rule": "gitkeep-handling.mdc" - }, - { - "pattern": "**/temp/", - "rule": ["temp-directory.mdc", "gitkeep-handling.mdc"] - }, - { - "pattern": "**/docker/template/src/", - "rule": ["source-code.mdc", "gitkeep-handling.mdc"] - }, - { - "pattern": "**/.woodpecker.yml", - "rule": "project-structure.mdc" - } - ] -} \ No newline at end of file +"version": 1, +"rules": [ +{ +"pattern": "**/*", +"rule": "project-structure.mdc" +}, +{ +"pattern": "**/docker/template/Dockerfile", +"rule": "dockerfiles.mdc" +}, +{ +"pattern": "**/docker/template/Dockerfile.production", +"rule": "dockerfiles.mdc" +}, +{ +"pattern": "**/docker-compose.dev.yml", +"rule": "docker-compose-files.mdc" +}, +{ +"pattern": "**/docker-compose.production.yml", +"rule": "docker-compose-files.mdc" +}, +{ +"pattern": "**/docker-compose.test.yml", +"rule": "docker-compose-files.mdc" +}, +{ +"pattern": "**/stack.production.yml", +"rule": "stack-files.mdc" +}, +{ +"pattern": "**/*.sh", +"rule": "scripts.mdc" +}, +{ +"pattern": "**/build-test-run.sh", +"rule": "git-workflow.mdc" +}, +{ +"pattern": "**/temp/**/*", +"rule": [ +"temp-directory.mdc", +"gitkeep-handling.mdc" +] +}, +{ +"pattern": "**/.gitignore", +"rule": "gitignore.mdc" +}, +{ +"pattern": "**/.git/**/*", +"rule": "git-workflow.mdc" +}, +{ +"pattern": "**/docker/template/src/**/*", +"rule": [ +"source-code.mdc", +"gitkeep-handling.mdc" +] +}, +{ +"pattern": "**/.gitkeep", +"rule": "gitkeep-handling.mdc" +}, +{ +"pattern": "**/temp/", +"rule": [ +"temp-directory.mdc", +"gitkeep-handling.mdc" +] +}, +{ +"pattern": "**/docker/template/src/", +"rule": [ +"source-code.mdc", +"gitkeep-handling.mdc" +] +}, +{ +"pattern": "**/.woodpecker.yml", +"rule": "project-structure.mdc" +} +] +} \ No newline at end of file diff --git a/.cursor/rules/docker-files.mdc b/.cursor/rules/docker-files.mdc index f7cb622..4e7f814 100644 --- a/.cursor/rules/docker-files.mdc +++ b/.cursor/rules/docker-files.mdc @@ -20,19 +20,11 @@ alwaysApply: false - Configures development environment variables - Mounts the [temp](mdc:temp) directory for local testing -- [docker-compose.staging.yml](mdc:docker-compose.staging.yml): Staging build configuration - - Builds and tags the staging image - - Used by CI/CD for staging deployments - - [docker-compose.production.yml](mdc:docker-compose.production.yml): Production build configuration - Builds and tags the production image - Used by CI/CD for production deployments ## Stack Files -- [stack.staging.yml](mdc:stack.staging.yml): Staging stack deployment - - Configures service deployment for staging environment - - Sets up Traefik routing rules - - [stack.production.yml](mdc:stack.production.yml): Production stack deployment - Configures service deployment for production environment - Sets up Traefik routing rules with appropriate security headers diff --git a/.woodpecker.yml b/.woodpecker.yml index 498f98b..13c51c0 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -10,70 +10,6 @@ clone: when: branch: [main] steps: - # Build and Push for Staging - build-push-staging: - name: build-push-staging - image: woodpeckerci/plugin-docker-buildx - environment: - REGISTRY_USER: - from_secret: REGISTRY_USER - REGISTRY_PASSWORD: - from_secret: REGISTRY_PASSWORD - DOCKER_REGISTRY_USER: - from_secret: DOCKER_REGISTRY_USER - DOCKER_REGISTRY_PASSWORD: - from_secret: DOCKER_REGISTRY_PASSWORD - volumes: - - /var/run/docker.sock:/var/run/docker.sock - commands: - - echo "nameserver 1.1.1.1" > /etc/resolv.conf - - echo "nameserver 1.0.0.1" >> /etc/resolv.conf - - HOSTNAME=$(docker info --format "{{.Name}}") - - echo "Building on $HOSTNAME" - - echo "$${DOCKER_REGISTRY_PASSWORD}" | docker login -u "$${DOCKER_REGISTRY_USER}" --password-stdin - - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - - docker compose -f docker-compose.staging.yml build --no-cache - - docker compose -f docker-compose.staging.yml push - when: - branch: main - event: push - - # Deploy Staging - deploy-staging: - name: deploy-staging - image: woodpeckerci/plugin-docker-buildx - environment: - REGISTRY_USER: - from_secret: REGISTRY_USER - REGISTRY_PASSWORD: - from_secret: REGISTRY_PASSWORD - volumes: - - /var/run/docker.sock:/var/run/docker.sock - commands: - - echo "nameserver 1.1.1.1" > /etc/resolv.conf - - echo "nameserver 1.0.0.1" >> /etc/resolv.conf - - HOSTNAME=$(docker info --format "{{.Name}}") - - echo "Deploying on $HOSTNAME" - - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - - docker stack deploy --with-registry-auth -c ./stack.staging.yml $${CI_REPO_NAME}-staging - when: - branch: main - event: push - - # Wait for Deploy to Complete - wait-for-deploy-staging: - name: wait-for-deploy-staging - image: woodpeckerci/plugin-docker-buildx - volumes: - - /var/run/docker.sock:/var/run/docker.sock - commands: - - echo "nameserver 1.1.1.1" > /etc/resolv.conf - - echo "nameserver 1.0.0.1" >> /etc/resolv.conf - - sleep 20 - when: - branch: main - event: push - # Build and Push for Production build-push-production: name: build-push-production @@ -122,28 +58,4 @@ steps: - docker stack deploy --with-registry-auth -c ./stack.production.yml $${CI_REPO_NAME} when: branch: main - event: [push, cron] - - # Cleanup Staging Environment - cleanup-staging: - name: cleanup-staging - image: woodpeckerci/plugin-docker-buildx - environment: - REGISTRY_USER: - from_secret: REGISTRY_USER - REGISTRY_PASSWORD: - from_secret: REGISTRY_PASSWORD - volumes: - - /var/run/docker.sock:/var/run/docker.sock - commands: - - echo "nameserver 1.1.1.1" > /etc/resolv.conf - - echo "nameserver 1.0.0.1" >> /etc/resolv.conf - - HOSTNAME=$(docker info --format "{{.Name}}") - - echo "Cleaning up staging environment on $HOSTNAME" - - 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 - when: - branch: main - event: [push, cron] - status: success \ No newline at end of file + event: [push, cron] \ No newline at end of file diff --git a/README.md b/README.md index f3bf1bc..40d2063 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@ This is a template project that follows a standardized structure for Docker-base ├── temp/ # Local testing scratch space ├── docker-compose.dev.yml # Docker Compose for local development ├── docker-compose.production.yml -├── docker-compose.staging.yml ├── docker-compose.test.yml -├── stack.staging.yml └── stack.production.yml ``` diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml deleted file mode 100644 index a96c565..0000000 --- a/docker-compose.staging.yml +++ /dev/null @@ -1,7 +0,0 @@ -# The only stuff that happens here is template gets replaced and so does possibly nixius -services: - template: - build: - context: ./docker/template - dockerfile: Dockerfile.staging - image: git.nixc.us/colin/template:staging \ No newline at end of file diff --git a/docker/template/Dockerfile.production b/docker/template/Dockerfile.production index 35a86f7..65fa3f8 100644 --- a/docker/template/Dockerfile.production +++ b/docker/template/Dockerfile.production @@ -1 +1,3 @@ -FROM git.nixc.us/nixius/template:staging +FROM alpine:3.18 +WORKDIR /app +CMD ["tail", "-f", "/dev/null"] diff --git a/stack.staging.yml b/stack.staging.yml deleted file mode 100644 index 5c4401a..0000000 --- a/stack.staging.yml +++ /dev/null @@ -1,33 +0,0 @@ -networks: - traefik: - external: true - default: - -services: - template: - image: git.nixc.us/nixius/template:staging - deploy: - labels: - - traefik.enable=true - - traefik.http.routers.staging_template.rule=Host(`staging.template.nixc.us`) - - traefik.http.routers.staging_template.entrypoints=websecure - - traefik.http.routers.staging_template.tls=true - - traefik.http.routers.staging_template.tls.certresolver=letsencryptresolver - - traefik.http.services.staging_template.loadbalancer.server.port=3000 - # - traefik.http.services.staging_template.loadbalancer.healthcheck.path=/health - # - traefik.http.services.staging_template.loadbalancer.healthcheck.interval=30s - # - traefik.http.services.staging_template.loadbalancer.healthcheck.timeout=5s - replicas: 1 - restart_policy: - condition: on-failure - max_attempts: 3 - update_config: - parallelism: 1 - delay: 10s - order: start-first - rollback_config: - parallelism: 1 - delay: 10s - order: stop-first - networks: - - traefik \ No newline at end of file