diff --git a/config/development/Dockerfile.client b/config/development/Dockerfile.client new file mode 100644 index 00000000..8a5ed925 --- /dev/null +++ b/config/development/Dockerfile.client @@ -0,0 +1,18 @@ +FROM node:18-alpine as server-dependencies + +RUN apk -U upgrade \ + && apk add build-base python3 \ + --no-cache + +WORKDIR /app/client +COPY package.json package-lock.json /app/client/ +RUN npm install npm@latest --global \ + && npm install pnpm --global \ + && pnpm import \ + && pnpm install + + +WORKDIR /app/ +COPY ../../package.json ../../package-lock.json /app/ +RUN pnpm import \ + && pnpm install diff --git a/config/development/Dockerfile.server b/config/development/Dockerfile.server new file mode 100644 index 00000000..0f51abec --- /dev/null +++ b/config/development/Dockerfile.server @@ -0,0 +1,14 @@ +FROM node:18-alpine as server-dependencies + +RUN apk -U upgrade \ + && apk add build-base python3 \ + --no-cache + +WORKDIR /app + +COPY package.json package-lock.json ./ + +RUN npm install npm@latest --global \ + && npm install pnpm --global \ + && pnpm import \ + && pnpm install diff --git a/config/development/nginx.conf b/config/development/nginx.conf new file mode 100644 index 00000000..94fc7d7b --- /dev/null +++ b/config/development/nginx.conf @@ -0,0 +1,47 @@ +user nginx; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + + location /api/ { + proxy_pass http://server:1337; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + + location /socket.io { + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://server:1337/socket.io; + } + + location / { + proxy_pass http://client:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + } +} diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 9fe70859..b3eccfd1 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -1,20 +1,18 @@ -version: '3' +version: '3.8' services: - planka: - image: ghcr.io/plankanban/planka:master - restart: on-failure - volumes: - - user-avatars:/app/public/user-avatars - - project-background-images:/app/public/project-background-images - - attachments:/app/private/attachments - ports: - - 3000:1337 - environment: - - BASE_URL=http://localhost:3000 - - DATABASE_URL=postgresql://postgres@postgres/planka - - SECRET_KEY=notsecretkey + server: + build: + context: ./server + dockerfile: ../config/development/Dockerfile.server + volumes: + - ./server:/app + - /app/node_modules + environment: + - NODE_ENV=development + - DATABASE_URL=postgresql://user:password@postgres:5432/planka_db + - SECRET_KEY=notsecretkey # - TRUST_PROXY=0 # - TOKEN_EXPIRES_IN=365 # In days @@ -25,20 +23,6 @@ services: # Configure knex to accept SSL certificates # - KNEX_REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false - - # - DEFAULT_ADMIN_EMAIL=demo@demo.demo # Do not remove if you want to prevent this user from being edited/deleted - # - DEFAULT_ADMIN_PASSWORD=demo - # - DEFAULT_ADMIN_NAME=Demo Demo - # - DEFAULT_ADMIN_USERNAME=demo - - # Email Notifications (https://nodemailer.com/smtp/) - # - SMTP_HOST= - # - SMTP_PORT=587 - # - SMTP_SECURE=true - # - SMTP_USER= - # - SMTP_PASSWORD= - # - SMTP_FROM="Demo Demo" - # - OIDC_ISSUER= # - OIDC_CLIENT_ID= # - OIDC_CLIENT_SECRET= @@ -51,26 +35,87 @@ services: # - OIDC_IGNORE_USERNAME=true # - OIDC_IGNORE_ROLES=true # - OIDC_ENFORCED=true + + # Email Notifications (https://nodemailer.com/smtp/) + # - SMTP_HOST= + # - SMTP_PORT=587 + # - SMTP_SECURE=true + # - SMTP_USER= + # - SMTP_PASSWORD= + # - SMTP_FROM="Demo Demo" + + # - SLACK_BOT_TOKEN= + # - SLACK_CHANNEL_ID= + + working_dir: /app + command: ["sh", "-c", "npm run start"] + depends_on: + postgres: + condition: service_healthy + + client: + build: + context: ./client + dockerfile: ../config/development/Dockerfile.client + volumes: + - ./client:/app/client + - /app/client/node_modules + - /app/node_modules + environment: + - NODE_ENV=development + - CHOKIDAR_USEPOLLING=true + - BASE_URL=http://localhost:3000 + - REACT_APP_SERVER_BASE_URL=http://localhost:3000 + working_dir: /app/client + command: npm start + + init-db: + build: + context: ./server + dockerfile: ../config/development/Dockerfile.server + environment: + - DATABASE_URL=postgresql://user:password@postgres:5432/planka_db + # - DEFAULT_ADMIN_EMAIL=demo@demo.demo # Do not remove if you want to prevent this user from being edited/deleted + # - DEFAULT_ADMIN_PASSWORD=demo + # - DEFAULT_ADMIN_NAME=Demo Demo + # - DEFAULT_ADMIN_USERNAME=demo + + working_dir: /app + command: ["sh", "-c", "npm run db:init"] + volumes: + - ./server:/app + - /app/node_modules depends_on: postgres: condition: service_healthy postgres: - image: postgres:14-alpine - restart: on-failure + image: postgres:latest volumes: - db-data:/var/lib/postgresql/data environment: - - POSTGRES_DB=planka - - POSTGRES_HOST_AUTH_METHOD=trust + POSTGRES_DB: planka_db + POSTGRES_USER: user + POSTGRES_PASSWORD: password + ports: + - "5432:5432" + restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres -d planka"] interval: 10s timeout: 5s retries: 5 + proxy: + image: nginx:alpine + ports: + - "3000:80" + volumes: + - ./config/development/nginx.conf:/etc/nginx/nginx.conf + depends_on: + - server + - client + + volumes: - user-avatars: - project-background-images: - attachments: db-data: