docker dan gitignore
This commit is contained in:
parent
850a72fd51
commit
c65f5fe374
93
.gitignore
vendored
Normal file
93
.gitignore
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# Created by https://www.gitignore.io
|
||||||
|
|
||||||
|
### OSX ###
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear on external disk
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
|
||||||
|
### Django ###
|
||||||
|
*.log
|
||||||
|
*.pot
|
||||||
|
*.pyc
|
||||||
|
__pycache__/
|
||||||
|
local_settings.py
|
||||||
|
nin/__pycache__/
|
||||||
|
|
||||||
|
.env
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# virtual env
|
||||||
|
env/
|
||||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: ./dockers/python
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
command: gunicorn hello_django.wsgi:application --bind 0.0.0.0:8000
|
||||||
|
volumes:
|
||||||
|
- static_volume:/home/app/web/staticfiles
|
||||||
|
- media_volume:/home/app/web/mediafiles
|
||||||
|
expose:
|
||||||
|
- 8000
|
||||||
|
# env_file:
|
||||||
|
# - ./.env.prod
|
||||||
|
# depends_on:
|
||||||
|
# - db
|
||||||
|
# db:
|
||||||
|
# image: postgres:15
|
||||||
|
# volumes:
|
||||||
|
# - postgres_data:/var/lib/postgresql/data/
|
||||||
|
# env_file:
|
||||||
|
# - ./.env.prod.db
|
||||||
|
nginx:
|
||||||
|
build:
|
||||||
|
context: ./dockers/nginx
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
volumes:
|
||||||
|
- static_volume:/home/app/web/staticfiles
|
||||||
|
- media_volume:/home/app/web/mediafiles
|
||||||
|
ports:
|
||||||
|
- 1337:80
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
static_volume:
|
||||||
|
media_volume:
|
||||||
4
dockers/nginx/Dockerfile
Normal file
4
dockers/nginx/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FROM nginx:1.28.0
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d
|
||||||
24
dockers/nginx/nginx.conf
Normal file
24
dockers/nginx/nginx.conf
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
upstream web_django {
|
||||||
|
server web:8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://web_django;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /home/app/web/staticfiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /home/app/web/mediafiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
60
dockers/python/Dockerfile
Normal file
60
dockers/python/Dockerfile
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# First stage: build the Python app
|
||||||
|
FROM python:3.13.3-bookworm
|
||||||
|
|
||||||
|
# create directory for the app user
|
||||||
|
RUN mkdir -p /home/app
|
||||||
|
|
||||||
|
# create the app user
|
||||||
|
RUN addgroup --system app && adduser --system --group app
|
||||||
|
|
||||||
|
# create the appropriate directories
|
||||||
|
ENV HOME=/home/app
|
||||||
|
ENV APP_HOME=/home/app/web
|
||||||
|
RUN mkdir $APP_HOME
|
||||||
|
RUN mkdir $APP_HOME/staticfiles
|
||||||
|
RUN mkdir $APP_HOME/mediafiles
|
||||||
|
WORKDIR $APP_HOME
|
||||||
|
|
||||||
|
# set environment variables
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
# install system dependencies
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends gcc
|
||||||
|
|
||||||
|
# lint
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
# RUN pip install flake8==6.0.0
|
||||||
|
# COPY . /usr/src/app/
|
||||||
|
# RUN flake8 --ignore=E501,F401 .
|
||||||
|
|
||||||
|
# install python dependencies
|
||||||
|
COPY ./requirements.txt .
|
||||||
|
# RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
# install dependencies
|
||||||
|
# RUN apt-get update && apt-get install -y --no-install-recommends netcat
|
||||||
|
# COPY --from=builder /usr/src/app/wheels /wheels
|
||||||
|
# COPY --from=builder /usr/src/app/requirements.txt .
|
||||||
|
# RUN pip install --upgrade pip
|
||||||
|
# RUN pip install --no-cache /wheels/*
|
||||||
|
|
||||||
|
# copy entrypoint.prod.sh
|
||||||
|
# COPY ./entrypoint.prod.sh .
|
||||||
|
# RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.prod.sh
|
||||||
|
# RUN chmod +x $APP_HOME/entrypoint.prod.sh
|
||||||
|
|
||||||
|
# copy project
|
||||||
|
COPY ../../. $APP_HOME
|
||||||
|
|
||||||
|
# chown all the files to the app user
|
||||||
|
RUN chown -R app:app $APP_HOME
|
||||||
|
|
||||||
|
# change to the app user
|
||||||
|
USER app
|
||||||
|
|
||||||
|
# run entrypoint.prod.sh
|
||||||
|
# ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
|
||||||
|
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
||||||
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
asgiref==3.8.1
|
||||||
|
Django==5.2
|
||||||
|
gunicorn==23.0.0
|
||||||
|
packaging==25.0
|
||||||
|
sqlparse==0.5.3
|
||||||
Loading…
Reference in New Issue
Block a user