/somepath/Designer_Docker
version: '3.8'
services:
designer_backend: # designer_backend
image: designer_backend
container_name: designer_backend
build:
context: .
dockerfile: ./designer_backend/Dockerfile
volumes:
- ./designer_backend/backend_server:/backend_server
expose:
- "8000"
# gunicorn 장고프로젝트명.wsgi:application --bind 0.0.0.0:8000
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
networks:
- backend
networks:
backend:
driver: bridge
/docker_project_dir/Designer_Docker/designer_backend
FROM python:3.9
# Configure python
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 PYTHONUNBUFFERED=1
ARG REQUIREMENT='requirements.txt'
RUN apt-get -y update && apt-get -y install vim && apt-get clean
RUN mkdir /backend_server
ADD . /backend_server
WORKDIR /backend_server
# get packages
# docekr-compose up -d --build 시에는 아래 COPY 명령어 사용
COPY ./designer_backend/$REQUIREMENT $REQUIREMENT
RUN pip install --upgrade pip
RUN pip install --upgrade django-rest-framework
RUN pip install --no-cache-dir -r ./$REQUIREMENT
COPY . /backend_server
# EXPOSE 8080 <= docker-compose.yml 에서 설정
# CMD ["python", "src/main.py"]
mysql-connector-python==8.0.31
redis==4.3.4
Django==4.2
gunicorn
djangorestframework
django-filter
djangorestframework-filters
drf-yasg
mysqlclient
requests
flex
ssv
(django_project_dir/WORKDIR/projectName
docker-compose run designer_backend django-admin startproject config .
mkdir ./backend_server/designer_server
docker-compose run designer_backend django-admin startapp designer_server ./designer_server
/docker_project_dir/nginx
FROM nginx:1.20.2
RUN rm /etc/nginx/nginx.conf
COPY ./nginx.conf /etc/nginx/
RUN rm /etc/nginx/conf.d/default.conf
COPY ./project.conf /etc/nginx/conf.d/
#ngnix.conf
#Define the user that will own and run the Nginx server
user nginx;
# Define the number of worker processes; recommended value is the number of
# cores that are being used by your server
worker_processes 1;
# Define the location on the file system of the error log, plus the minimum
# severity to log messages for
error_log /var/log/nginx/error.log warn;
# Define the file that will store the process ID of the main NGINX process
pid /var/run/nginx.pid;
# events block defines the parameters that affect connection processing.
events {
# Define the maximum number of simultaneous connections that can be opened by a worker process
worker_connections 1024;
}
# http block defines the parameters for how NGINX should handle HTTP web traffic
http {
# Include the file defining the list of file types that are supported by NGINX
include /etc/nginx/mime.types;
# Define the default file type that is returned to the user
default_type text/html;
# Define the format of log messages.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Define the location of the log of access attempts to NGINX
access_log /var/log/nginx/access.log main;
# Define the parameters to optimize the delivery of static content
sendfile on;
tcp_nopush on;
tcp_nodelay on;
# Define the timeout value for keep-alive connections with the client
keepalive_timeout 65;
# Define the usage of the gzip compression algorithm to reduce the amount of data to transmit
#gzip on;
# Include additional parameters for virtual host(s)/server(s)
include /etc/nginx/conf.d/*.conf;
}
# nginx 가 80 port listen 하고 있다가, designer_backend:8000에 연결
# designer_backend upstream 설정
upstream designer_backend {
server designer_backend:8000;
}
server {
listen 80;
# server_name localhost;
server_name designer_backend;
location / {
proxy_pass http://designer_backend;
# proxy_pass http://localhost:8000;
# Do not change this
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias /static/;
}
}
version: '3.8'
services:
nginx:
container_name: nginx
image: nginx
build: ./nginx
ports:
# 외부 포트: 내부 포트
# designer_backend port mapping
- "80:80"
# server port mapping sample
# - "8080:8080"
volumes:
- ./nginx:/etc/nginx.conf.d
- ./.static_root:/static
depends_on:
- designer_backend
networks:
- backend
designer_backend: # designer_backend
image: designer_backend
container_name: designer_backend
build:
context: .
dockerfile: ./designer_backend/Dockerfile
volumes:
- ./designer_backend/backend_server:/backend_server
expose:
- "8000"
# python manage.py runserver 0:8000 역할을 gunicorn 에서 수행
# gunicorn 장고프로젝트명.wsgi:application --bind 0.0.0.0:8000
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
networks:
- backend
networks:
backend:
driver: bridge
docker-compose build
docker-compose up
(이미지 build 하고 container 실행)
또는
(container 실행 시 이미지 build)
docker-compose up --build
/docker_project_dir/postgresql
version: '3.8'
services:
nginx:
container_name: nginx
image: nginx
build: ./nginx
ports:
# 외부 포트: 내부 포트
# designer_backend port mapping
- "80:80"
# server port mapping sample
# - "8080:8080"
volumes:
- ./nginx:/etc/nginx.conf.d
- ./designer_backend/backend_server/.static_root/:/static
depends_on:
- designer_backend
networks:
- backend
postgresql:
image: postgres:latest
container_name: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
volumes:
- ./postgresql/data:/var/lib/postgresql/data
networks:
- backend
designer_backend: # designer_backend
image: designer_backend
container_name: designer_backend
build:
context: .
dockerfile: ./designer_backend/Dockerfile
volumes:
- ./designer_backend/backend_server:/backend_server
depends_on:
- redis
- postgresql
- mssql
- mysql
expose:
- "8000"
# python manage.py runserver 0:8000 역할을 gunicorn 에서 수행
# gunicorn 장고프로젝트명.wsgi:application --bind 0.0.0.0:8000
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
networks:
- backend
networks:
backend:
driver: bridge
/docker_project_dir/mysql
/docker_project_dir/mysql/conf.d
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
/docker_project_dir/mysql/data
/docker_project_dir/mysql/initdb.d
version: '3.8'
services:
nginx:
container_name: nginx
image: nginx
build: ./nginx
ports:
# 외부 포트: 내부 포트
# designer_backend port mapping
- "80:80"
# server port mapping sample
# - "8080:8080"
volumes:
- ./nginx:/etc/nginx.conf.d
- ./designer_backend/backend_server/.static_root/:/static
depends_on:
- designer_backend
networks:
- backend
postgresql:
image: postgres:latest
container_name: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
volumes:
- ./postgresql/data:/var/lib/postgresql/data
networks:
- backend
mysql: # See Also: https://hub.docker.com/_/mysql
container_name: mysql
image: mysql:8.0.31
hostname: hostname-mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: designer_app
# MYSQL_USER: root
MYSQL_PASSWORD: root
TZ: Asia/Seoul
networks:
- backend
ports:
- "3306:3306"
volumes:
- ./mysql/conf.d:/etc/mysql/conf.d
- ./mysql/data:/var/lib/mysql
- ./mysql/initdb.d:/docker-entrypoint-initdb.d
# env_file: .env
expose:
- "3306"
designer_backend: # designer_backend
image: designer_backend
container_name: designer_backend
build:
context: .
dockerfile: ./designer_backend/Dockerfile
volumes:
- ./designer_backend/backend_server:/backend_server
depends_on:
- redis
- postgresql
- mssql
- mysql
expose:
- "8000"
# python manage.py runserver 0:8000 역할을 gunicorn 에서 수행
# gunicorn 장고프로젝트명.wsgi:application --bind 0.0.0.0:8000
command: gunicorn config.wsgi:application --bind 0.0.0.0:8000
networks:
- backend
networks:
backend:
driver: bridge