Skip to content

Commit

Permalink
feat: Development environment with docker compose (plankanban#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonvnt authored and robertocjunior committed May 14, 2024
1 parent a8557a3 commit 05e0dfd
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 33 deletions.
18 changes: 18 additions & 0 deletions config/development/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions config/development/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions config/development/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
111 changes: 78 additions & 33 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
version: '3'
version: '3.8'

services:
planka:
image: ghcr.io/plankanban/planka:master
restart: on-failure

server:
build:
context: ./server
dockerfile: ../config/development/Dockerfile.server
volumes:
- user-avatars:/app/public/user-avatars
- project-background-images:/app/public/project-background-images
- attachments:/app/private/attachments
ports:
- 3000:1337
- ./server:/app
- /app/node_modules
environment:
- BASE_URL=http://localhost:3000
- DATABASE_URL=postgresql://postgres@postgres/planka
- NODE_ENV=development
- DATABASE_URL=postgresql://user:password@postgres:5432/planka_db
- SECRET_KEY=notsecretkey

# - TRUST_PROXY=0
# - TOKEN_EXPIRES_IN=365 # In days

Expand All @@ -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" <demo@demo.demo>

# - OIDC_ISSUER=
# - OIDC_CLIENT_ID=
# - OIDC_CLIENT_SECRET=
Expand All @@ -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" <demo@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:

0 comments on commit 05e0dfd

Please sign in to comment.