chore: Portainer-compatible docker-compose, improved .dockerignore

- Use image reference instead of build context for Portainer stacks
- Inline all environment variables (no env_file dependency)
- Add .next, logs, Inspiration to .dockerignore
- Explicit .env.local and .env.production in .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-02-22 23:52:49 +01:00
parent 02a8c2a0b4
commit b46c7b7ccb
3 changed files with 38 additions and 28 deletions

View File

@ -1,12 +1,15 @@
node_modules
.npm
.next
.git
.gitignore
Dockerfile
docker-compose*.yml
.env
.env.local
.env.*
.planning
prisma/dev.db
*.md
!prisma/**/*.md
logs
Inspiration

View File

@ -4,9 +4,13 @@ set -e
# Deploy script for My Weekly To-Do List
# Usage: ./deploy.sh [version]
# Example: ./deploy.sh 1.1.0
#
# Builds the Docker image locally, then restarts the Portainer stack.
# The Portainer stack references "my-weekly-todo:latest".
APP_NAME="my-weekly-todo"
COMPOSE_FILE="docker-compose.yml"
IMAGE_NAME="my-weekly-todo"
PORTAINER_STACK="my-weekly-todo"
# Colors
GREEN='\033[0;32m'
@ -42,26 +46,19 @@ if [ -n "$VERSION" ]; then
echo -e "${GREEN}Tagged v$VERSION${NC}"
fi
# Run database migrations
echo -e "${YELLOW}Running database migrations...${NC}"
docker compose -f "$COMPOSE_FILE" run --rm app npx prisma migrate deploy 2>/dev/null || true
# Build and deploy
echo -e "${YELLOW}Building production image...${NC}"
docker compose -f "$COMPOSE_FILE" build --no-cache
echo -e "${YELLOW}Starting services...${NC}"
docker compose -f "$COMPOSE_FILE" up -d
# Wait for health check
echo -e "${YELLOW}Waiting for health check...${NC}"
sleep 10
if docker compose -f "$COMPOSE_FILE" ps | grep -q "healthy"; then
echo -e "${GREEN}Deployment successful!${NC}"
else
echo -e "${YELLOW}Services started (health check may still be warming up)${NC}"
docker compose -f "$COMPOSE_FILE" ps
fi
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo -e "${GREEN}=== Deployed v$CURRENT_VERSION ===${NC}"
# Build Docker image
echo -e "${YELLOW}Building production image ${IMAGE_NAME}:${CURRENT_VERSION}...${NC}"
docker build -t "${IMAGE_NAME}:${CURRENT_VERSION}" -t "${IMAGE_NAME}:latest" .
# Restart the Portainer stack (pull new image)
echo -e "${YELLOW}Restarting Portainer stack...${NC}"
echo -e "${YELLOW}Go to Portainer > Stacks > ${PORTAINER_STACK} > click 'Update the stack' > 'Re-pull image and redeploy'${NC}"
echo ""
echo -e "Or restart via CLI:${NC}"
echo -e " docker compose -f docker-compose.yml up -d"
echo ""
echo -e "${GREEN}=== Image ${IMAGE_NAME}:${CURRENT_VERSION} ready ===${NC}"
echo -e "${GREEN}=== Also tagged as ${IMAGE_NAME}:latest ===${NC}"

View File

@ -2,20 +2,29 @@ version: '3.8'
services:
app:
build: .
image: my-weekly-todo:latest
ports:
- "13000:3000"
env_file:
- .env.production
environment:
- DATABASE_URL=postgresql://root:WKE7xeZohxdZit7eObjG@db:5432/My-Weekly-ToDo-List?schema=public
- NEXTAUTH_SECRET=Ca7EoJzZSMJO2CkqwdWd
- NEXTAUTH_URL=https://todo.martin-bierschenk.de
- NEXT_PUBLIC_BASE_URL=https://todo.martin-bierschenk.de
- SMTP_HOST=w00ff033.kasserver.com
- SMTP_PORT=587
- SMTP_USERNAME=mail@carrylight.de
- SMTP_PASSWORD=QijU8e2A8p3FE8WS8esR
- SMTP_SECURE=true
- GOOGLE_CLIENT_ID=196368743757-1fn17q2ecg5n8rej4tu96khltno173he.apps.googleusercontent.com
- GOOGLE_CLIENT_SECRET=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
- GOOGLE_REDIRECT_URI=https://todo.martin-bierschenk.de/api/calendar/google/oauth
- MICROSOFT_CLIENT_ID=a6ea3972-2e4a-4a24-b50f-4047867d8de3
- MICROSOFT_CLIENT_SECRET=9649da1a-9057-4ac5-ad5a-73cf1cef9478
- MICROSOFT_REDIRECT_URI=https://todo.martin-bierschenk.de/api/calendar/outlook/callback
depends_on:
- db
volumes:
- ./logs:/app/logs
- app_logs:/app/logs
restart: unless-stopped
db:
@ -32,3 +41,4 @@ services:
volumes:
postgres_data:
app_logs: