Skip to content

Commit

Permalink
Change deploy settings of the playground app
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeHanYeong committed Jun 20, 2022
1 parent 2b26c68 commit 82566af
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 272 deletions.
1 change: 1 addition & 0 deletions .deploy/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOCKERFILE=Dockerfile
1 change: 1 addition & 0 deletions .deploy/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOCKERFILE=Dockerfile.deploy
22 changes: 0 additions & 22 deletions .deploy/docker-compose.yml

This file was deleted.

82 changes: 0 additions & 82 deletions .deploy/init.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .deploy/nginx/cert.nginx

This file was deleted.

31 changes: 0 additions & 31 deletions .deploy/nginx/local.nginx

This file was deleted.

31 changes: 0 additions & 31 deletions .deploy/nginx/nginx.conf

This file was deleted.

28 changes: 0 additions & 28 deletions .deploy/nginx/production.nginx

This file was deleted.

22 changes: 22 additions & 0 deletions .deploy/quill.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
server {
listen 80;
server_name quill.localhost quill.lhy.kr;

location / {
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass_header Server;
proxy_pass http://django:8000;
proxy_redirect off;
}
location /static/ {
alias /srv/playground/.static/;
}
location /favicon.ico {
alias /srv/playground/.static/favicon.ico;
}
}
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# syntax = docker/dockerfile:experimental
FROM python:3.9-slim
FROM python:3.10-alpine

# Language, Timezone
ENV LANG C.UTF-8

RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt -y update &&\
apt -y dist-upgrade &&\
apt -y autoremove

# requirements
COPY requirements.txt /tmp/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
Expand All @@ -22,4 +17,4 @@ COPY . /srv/
WORKDIR /srv/playground

EXPOSE 8000
CMD python manage.py shell_plus --ipython
CMD python manage.py shell_plus
9 changes: 2 additions & 7 deletions Dockerfile.deploy
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# syntax = docker/dockerfile:experimental
FROM python:3.9-slim
FROM python:3.10-alpine

# Language, Timezone
ENV LANG C.UTF-8

RUN \
apt -y update &&\
apt -y dist-upgrade &&\
apt -y autoremove

# requirements
COPY requirements.txt /tmp/requirements.txt
RUN \
Expand All @@ -22,4 +17,4 @@ COPY . /srv/
WORKDIR /srv/playground

EXPOSE 8000
CMD python manage.py shell_plus --ipython
CMD python manage.py shell_plus
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ python -m http.server 3001
### docker-compose up (in local)
### docker-compose up
```shell
docker-compose -f docker-compose-local.yml up --build --force-recreate --remove-orphans
# local
docker-compose --env-file .deploy/.env.local up --build --force-recreate --remove-orphans
# production
docker-compose --env-file .deploy/.env.production up --build --force-recreate --remove-orphans
```

28 changes: 0 additions & 28 deletions docker-compose-local.yml

This file was deleted.

23 changes: 3 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,20 @@ version: '3'
services:
quill:
image: nginx:alpine
restart: unless-stopped
volumes:
- ./.deploy/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./.deploy/nginx/production.nginx:/etc/nginx/conf.d/default.conf
- ./.deploy/certbot/conf:/etc/letsencrypt
- ./.deploy/certbot/www:/var/www/certbot
- .deploy/quill.conf:/etc/nginx/conf.d/default.conf
- static:/srv/playground/.static
depends_on:
- django
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
networks:
- default
- proxy

certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- /etc/letsencrypt:/etc/letsencrypt
- /var/www/certbot:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
networks:
- default

django:
build:
context: .
dockerfile: Dockerfile.deploy
dockerfile: ${DOCKERFILE}
volumes:
- static:/srv/playground/.static
command: bash -c '
command: sh -c '
python manage.py collectstatic --noinput &&
python manage.py migrate --noinput &&
gunicorn -c /srv/.deploy/gunicorn.py config.wsgi'
Expand Down
1 change: 1 addition & 0 deletions playground/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"quill.localhost",
"quill.lhy.kr",
]

Expand Down
2 changes: 1 addition & 1 deletion playground/posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def get_absolute_url(self):

class NonQuillPost(models.Model):
content_char = CharField(max_length=300, blank=True)
content_text = QuillField()
content_text = TextField(blank=True)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.10"
Django = "^3.2.9"
django-extensions = "^3.1.5"
djangorestframework = "^3.13.1"
Expand Down

0 comments on commit 82566af

Please sign in to comment.