refactor: create docker-stack workspace for deployment configs

Created dedicated workspace for Docker deployment configurations and scripts.
Improves organization by grouping all deployment-related files together.

## New Structure
- docker-stack/: Docker Compose files and deployment scripts
  - docker-compose-standalone.yaml
  - docker-compose-swarm.yml
  - docker-compose-debug.yml
  - deploy-standalone.sh
  - deploy-swarm.sh
  - README.md (deployment documentation)
  - package.json

## Changes
- Moved all docker-compose YAML files to docker-stack/
- Moved deploy scripts to docker-stack/
- Updated VS Code workspace to include docker-stack
- Updated documentation (README, CLAUDE.md)

## Deployment Workflow
1. Build: `cd web-app && ./build.sh 2.20.0`
2. Deploy: `cd docker-stack && ./deploy-standalone.sh 2.20.0`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-12-25 13:21:46 +01:00
parent b4424edd4e
commit 36accc3b30
10 changed files with 74 additions and 6 deletions

46
docker-stack/README.md Normal file
View File

@@ -0,0 +1,46 @@
# Docker Stack
Docker Compose configurations and deployment scripts for the Evidencija Režija application.
## Files
### Docker Compose Configurations
- `docker-compose-standalone.yaml` - Standalone deployment with docker-compose
- `docker-compose-swarm.yml` - Docker Swarm deployment
- `docker-compose-debug.yml` - Debug/development deployment
### Deployment Scripts
- `deploy-standalone.sh` - Deploy standalone configuration
- `deploy-swarm.sh` - Deploy swarm configuration
## Usage
### Deploying Standalone
```bash
cd docker-stack
./deploy-standalone.sh 2.20.0
```
### Deploying to Swarm
```bash
cd docker-stack
./deploy-swarm.sh 2.20.0
```
## Prerequisites
- Docker image must be built first: `cd ../web-app && ./build.sh 2.20.0`
- MongoDB data directory: `../mongo-volume/`
- MongoDB backup directory: `../mongo-backup/`
## Configuration
All compose files reference:
- Web app image: `utility-bills-tracker:${IMAGE_VERSION}`
- Volume mounts: `../web-app/etc/hosts/`
- MongoDB data: `../mongo-volume/`
- MongoDB backups: `../mongo-backup/`

View File

@@ -0,0 +1,18 @@
#!/bin/bash
if [ "$1" == "" ] ; then
printf "\nDocker image-a version param missing"
printf "\n\nSyntax:\n\n deploy-standalone.sh 1.0.0\n\n"
exit 1
fi
printf "\nBUILD START ...\n\n"
IMAGE_VERSION=$1
COMPOSE_FILE="docker-compose-standalone.yaml"
echo "Deploying with image version: $IMAGE_VERSION"
# Pass IMAGE_VERSION env var for compose variable substitution
IMAGE_VERSION="$IMAGE_VERSION" docker compose \
-f "$COMPOSE_FILE" \
up -d

18
docker-stack/deploy-swarm.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
if [ "$1" == "" ] ; then
printf "\nDocker image-a version param missing"
printf "\n\nSyntax:\n\n deploy-swarm.sh 1.0.0\n\n"
exit 1
fi
printf "\nBUILD START ...\n\n"
IMAGE_VERSION=$1
COMPOSE_FILE="docker-compose-swarm.yml"
echo "Deploying with image version: $IMAGE_VERSION"
# Pass IMAGE_VERSION env var for compose variable substitution
IMAGE_VERSION="$IMAGE_VERSION" docker stack deploy \
-c "$COMPOSE_FILE" \
utility-bills-tracker

View File

@@ -0,0 +1,31 @@
# this compose file runs Postgres db and exposes it's port to the host machine
version: "3.7"
services:
mongo:
image: mongo:4.4.27
container_name: evidencija-rezija__mongo
ulimits:
nofile:
soft: 64000
hard: 64000
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: HjktJCPWMBtM1ACrDaw7
volumes:
- ./mongo-volume:/data/db
- ./mongo-backup:/backup
mongo-express:
image: mongo-express
container_name: evidencija-rezija__mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: HjktJCPWMBtM1ACrDaw7
ME_CONFIG_MONGODB_URL: mongodb://root:HjktJCPWMBtM1ACrDaw7@mongo:27017/

View File

@@ -0,0 +1,81 @@
# docker-compose.yml
version: "3.9"
networks:
traefik-network:
name: traefik-network
external: true
util-bills-mongo-network:
name: "util-bills-mongo-network"
attachable: false
external: false
internal: true # bridge network, isolated from host and other networks
services:
web-app:
image: utility-bills-tracker:${IMAGE_VERSION}
networks:
- traefik-network
- util-bills-mongo-network
volumes:
- ./web-app/etc/hosts/:/etc/hosts
environment:
MONGODB_URI: mongodb://rezije.app:w4z4piJBgCdAm4tpawqB@mongo:27017/utility-bills
GOOGLE_ID: 355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
GOOGLE_SECRET: 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
AUTH_SECRET: Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
LINKEDIN_ID: 776qlcsykl1rag
LINKEDIN_SECRET: ugf61aJ2iyErLK40
HOSTNAME: rezije.app # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
NEXTAUTH_URL: https://rezije.app # URL next-auth will use while redirecting user during authentication (if not set - will use HOSTNAME)
PORT: ${PORT:-80}
# Share link security
SHARE_LINK_SECRET: ef68362357315d5decb27d24ff9abdb4a02a3351cd2899f79bf238dce0fe08c5
SHARE_TTL_INITIAL_DAYS: 10
SHARE_TTL_AFTER_VISIT_HOURS: 1
# Upload rate limiting
UPLOAD_RATE_LIMIT_PER_IP: 5
UPLOAD_RATE_LIMIT_WINDOW_MS: 3600000
container_name: evidencija-rezija__web-app
restart: unless-stopped # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
depends_on:
- mongo
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.web-app.loadbalancer.server.port=80
- traefik.http.routers.web-app.entrypoints=http
- traefik.http.routers.web-app.rule=Host(`${FQDN:-rezije.app}`)
mongo:
image: mongo:4.4.27
container_name: evidencija-rezija__mongo
restart: unless-stopped # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
volumes:
- ./mongo-volume:/data/db
- ./mongo-backup:/backup
networks:
- util-bills-mongo-network
mongo-express:
image: mongo-express
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: HjktJCPWMBtM1ACrDaw7
ME_CONFIG_MONGODB_URL: mongodb://root:HjktJCPWMBtM1ACrDaw7@mongo:27017/
networks:
- traefik-network
- util-bills-mongo-network
container_name: evidencija-rezija__mongo-express
restart: unless-stopped
depends_on:
- mongo
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.mongo-express.loadbalancer.server.port=8081
- traefik.http.routers.mongo-express.entrypoints=http
- traefik.http.routers.mongo-express.rule=Host(`mongo.rezije.app`)

View File

@@ -0,0 +1,81 @@
# this compose file runs Postgres db and exposes it's port to the host machine
version: "3.7"
networks:
traefik-network:
name: "traefik-network"
external: true
util-bills-mongo-network:
name: "util-bills-mongo-network"
attachable: false
external: false
internal: true # bridge network, isolated from host and other networks
services:
web-app:
image: utility-bills-tracker:${IMAGE_VERSION}
networks:
- traefik-network
- util-bills-mongo-network
volumes:
- ./web-app/etc/hosts/:/etc/hosts
environment:
MONGODB_URI: mongodb://rezije.app:w4z4piJBgCdAm4tpawqB@mongo:27017/utility-bills
GOOGLE_ID: 355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
GOOGLE_SECRET: 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
AUTH_SECRET: Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
LINKEDIN_ID: 776qlcsykl1rag
LINKEDIN_SECRET: ugf61aJ2iyErLK40
HOSTNAME: rezije.app # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
NEXTAUTH_URL: https://rezije.app # URL next-auth will use while redirecting user during authentication (if not set - will use HOSTNAME)
PORT: ${PORT:-80}
# Share link security
SHARE_LINK_SECRET: ef68362357315d5decb27d24ff9abdb4a02a3351cd2899f79bf238dce0fe08c5
SHARE_TTL_INITIAL_DAYS: 10
SHARE_TTL_AFTER_VISIT_HOURS: 1
# Upload rate limiting
UPLOAD_RATE_LIMIT_PER_IP: 5
UPLOAD_RATE_LIMIT_WINDOW_MS: 3600000
deploy:
# u slucaju rušenja kontejnera čekamo 5s i dižemo novi kontejner => ako se i on sruši opet ceka 5s i pokusava ponovno (tako 5 puta)
restart_policy:
condition: any
delay: 5s
max_attempts: 0 # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.web-app.loadbalancer.server.port=80
- traefik.http.routers.web-app.entrypoints=http
- traefik.http.routers.web-app.rule=Host(`${FQDN:-rezije.app}`)
mongo:
image: mongo:4.4.27
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
volumes:
- ./mongo-volume:/data/db
networks:
- util-bills-mongo-network
mongo-express:
image: mongo-express
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: HjktJCPWMBtM1ACrDaw7
ME_CONFIG_MONGODB_URL: mongodb://root:HjktJCPWMBtM1ACrDaw7@mongo:27017/
networks:
- traefik-network
- util-bills-mongo-network
deploy:
# u slucaju rušenja kontejnera čekamo 5s i dižemo novi kontejner => ako se i on sruši opet ceka 5s i pokusava ponovno (tako 5 puta)
restart_policy:
condition: any
delay: 5s
max_attempts: 0 # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.mongo-express.loadbalancer.server.port=8081
- traefik.http.routers.mongo-express.entrypoints=http
- traefik.http.routers.mongo-express.rule=Host(`mongo.rezije.app`)

10
docker-stack/package.json Normal file
View File

@@ -0,0 +1,10 @@
{
"name": "docker-stack",
"version": "2.20.0",
"private": true,
"description": "Docker deployment configurations and scripts",
"scripts": {
"deploy:standalone": "./deploy-standalone.sh",
"deploy:swarm": "./deploy-swarm.sh"
}
}