Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dev docker compose #5

Merged
merged 17 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# common settings
TZ=Asia/Shanghai
NETWORKS_DRIVER=bridge


# resource limit
LIMIT_MEMORY_DATABASE=2G
LIMIT_MEMORY_REDIS=2G


# PATHS
DATABASE_PATH=./data/database # data storage path
REDIS_PATH=./data/redis # redis data storage path


# DATABASE
DATABASE_PORT=3306
DATABASE_USERNAME=admin
DATABASE_PASSWORD=123456
DATABASE_NAME=dev-database # database name

# REDIS
REDIS_PORT=6379
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ cython_debug/

.pdm-python
*.db

data/**
2 changes: 2 additions & 0 deletions backend/.flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=bamboo
FLASK_ENV=development
49 changes: 49 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
networks:
innerNetwork:
driver: ${NETWORKS_DRIVER}

services:
backend:
build:
context: ./backend
dockerfile: ./docker/backend/Dockerfile`
environment:
DATABASE_URL: postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@database:5432/${DATABASE_NAME}
# todo ...

database:
image: postgres:16
privileged: true
environment:
- TZ=${TZ}
- POSTGRES_USER=${DATABASE_USERNAME}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
- POSTGRES_DB=${DATABASE_NAME}
volumes:
- ${DATABASE_PATH}:/var/lib/postgresql/data
ports:
- "${DATABASE_PORT}:5432"
networks:
- innerNetwork
deploy:
resources:
limits:
memory: ${LIMIT_MEMORY_DATABASE}
restart: always

redis:
image: redis:5.0
environment:
- TZ=${TZ}
privileged: true
volumes:
- ${REDIS_PATH}:/data
ports:
- "${REDIS_PORT}:6379"
networks:
- innerNetwork
deploy:
resources:
limits:
memory: ${LIMIT_MEMORY_REDIS}
restart: always
30 changes: 30 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frontend build stage
FROM node:latest AS frontend_builder

WORKDIR /bamboo_builder/frontend
COPY ./frontend ./

# install pnpm
RUN npm install -g pnpm

# install frontend dependencies
RUN pnpm install

# build frontend static files
RUN pnpm run build

FROM python:3.12.1

WORKDIR /bamboo

# copy bamboo backend files
COPY ./backend ./

# copy frontend static files to APIFlask static folder
COPY --from=frontend_builder /bamboo/frontend/dist /bamboo/backend/static
# install requirements
RUN pip install -r requirements.txt
# install gunicorn
RUN pip install gunicorn

CMD [ "gunicorn", "app:app" ]