-
Notifications
You must be signed in to change notification settings - Fork 0
Containerize Application via Dockerfile #1
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
base: develop
Are you sure you want to change the base?
Changes from all commits
a1b252c
7db2ad1
0f2be0f
5f7eb5b
3314675
c5ba2b4
7082a8d
3f35757
3944e80
c4359e8
b2ff57d
6848d6d
22f6ee5
8578187
c30f0e1
b078b7e
f8a2311
24dab47
52d0d66
85acb0d
a20783c
6ae436f
b746487
f558b0e
a8e1ac4
73229c4
29863e1
bc6c749
a1abf3f
1460cbf
f9550e8
68e8129
a769a1b
35def21
0eee093
dea4722
57c843a
af185de
af36d4c
1ca8e7a
d5ff410
346e5a5
003dd4b
f5e1b65
9ce235b
fc75d37
87275ff
aa5ef8a
6a1b839
378b1f2
48d4483
dd6eba6
4b9ef3f
73f0233
9342b8a
5fc332e
87bf64f
1a5afb4
e027e45
dd1a97c
eb8beb6
ffe5ab1
f34633b
7fc9fa8
08ca2f5
e2b5004
eafe260
dff722c
b290711
6e33709
37b1520
0204747
3ae8000
4cbca7e
da574ea
8f4b0d0
09d90a2
1b22925
1fd668a
63b9cd1
8720421
d89f9d4
3353f2f
9e78309
8b870dd
0698fa0
966dd8d
2e2f272
506a12f
c0519cc
5abc80d
211ee01
e9818f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,219 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[codz] | ||
hepheir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # 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/ | ||
| .nox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.py.cover | ||
| .hypothesis/ | ||
| .pytest_cache/ | ||
| cover/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
| db.sqlite3-journal | ||
|
|
||
| # Flask stuff: | ||
| instance/ | ||
| .webassets-cache | ||
|
|
||
| # Scrapy stuff: | ||
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| .pybuilder/ | ||
| target/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
|
|
||
| # IPython | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # pyenv | ||
| # For a library or package, you might want to ignore these files since the code is | ||
| # intended to run in multiple environments; otherwise, check them in: | ||
| # .python-version | ||
|
|
||
| # pipenv | ||
| # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
| # However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
| # having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
| # install all needed dependencies. | ||
| # Pipfile.lock | ||
|
|
||
| # UV | ||
| # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. | ||
| # This is especially recommended for binary packages to ensure reproducibility, and is more | ||
| # commonly ignored for libraries. | ||
| # uv.lock | ||
|
|
||
| # poetry | ||
| # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
| # This is especially recommended for binary packages to ensure reproducibility, and is more | ||
| # commonly ignored for libraries. | ||
| # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
| # poetry.lock | ||
| # poetry.toml | ||
|
|
||
| # pdm | ||
| # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
| # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. | ||
| # https://pdm-project.org/en/latest/usage/project/#working-with-version-control | ||
| # pdm.lock | ||
| # pdm.toml | ||
| .pdm-python | ||
| .pdm-build/ | ||
|
|
||
| # pixi | ||
| # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. | ||
| # pixi.lock | ||
| # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one | ||
| # in the .venv directory. It is recommended not to include this directory in version control. | ||
| .pixi | ||
|
|
||
| # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
| __pypackages__/ | ||
|
|
||
| # Celery stuff | ||
| celerybeat-schedule | ||
| celerybeat.pid | ||
|
|
||
| # Redis | ||
| *.rdb | ||
| *.aof | ||
| *.pid | ||
|
|
||
| # RabbitMQ | ||
| mnesia/ | ||
| rabbitmq/ | ||
| rabbitmq-data/ | ||
|
|
||
| # ActiveMQ | ||
| activemq-data/ | ||
|
|
||
| # SageMath parsed files | ||
| *.sage.py | ||
|
|
||
| # Environments | ||
| .env | ||
| .envrc | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # Spyder project settings | ||
| .spyderproject | ||
| .spyproject | ||
|
|
||
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # mkdocs documentation | ||
| /site | ||
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # pytype static type analyzer | ||
| .pytype/ | ||
|
|
||
| # Cython debug symbols | ||
| cython_debug/ | ||
|
|
||
| # PyCharm | ||
| # JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
| # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
| # and can be added to the global gitignore or merged into this file. For a more nuclear | ||
| # option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
| # .idea/ | ||
|
|
||
| # Abstra | ||
| # Abstra is an AI-powered process automation framework. | ||
| # Ignore directories containing user credentials, local state, and settings. | ||
| # Learn more at https://abstra.io/docs | ||
| .abstra/ | ||
|
|
||
| # Visual Studio Code | ||
| # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore | ||
| # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore | ||
| # and can be added to the global gitignore or merged into this file. However, if you prefer, | ||
| # you could uncomment the following to ignore the entire vscode folder | ||
| # .vscode/ | ||
|
|
||
| # Ruff stuff: | ||
| .ruff_cache/ | ||
|
|
||
| # PyPI configuration file | ||
| .pypirc | ||
|
|
||
| # Marimo | ||
| marimo/_static/ | ||
| marimo/_lsp/ | ||
| __marimo__/ | ||
|
|
||
| # Streamlit | ||
| .streamlit/secrets.toml | ||
|
|
||
| # Dot files | ||
| .* | ||
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| FROM python:3.11-slim | ||||||
|
|
||||||
| # Set the working directory inside the container | ||||||
| WORKDIR /app | ||||||
|
|
||||||
| # Set environment variables | ||||||
| # Prevents Python from writing pyc files to disk | ||||||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||||||
| # Prevents Python from buffering stdout and stderr | ||||||
| ENV PYTHONUNBUFFERED=1 | ||||||
|
|
||||||
| # Copy the Django project and install dependencies | ||||||
| COPY requirements.txt /app/ | ||||||
|
|
||||||
| # Run this command to install all dependencies | ||||||
| RUN pip install --upgrade pip && \ | ||||||
| pip install --no-cache-dir -r requirements.txt && \ | ||||||
| apt-get update && \ | ||||||
| apt-get install -y curl && \ | ||||||
| rm -rf /var/lib/apt/lists/* | ||||||
|
|
||||||
| COPY . /app/ | ||||||
|
|
||||||
| # Create non-root user | ||||||
| RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app | ||||||
| USER appuser | ||||||
|
|
||||||
| # Schedule health check | ||||||
| HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD ["curl", "--silent", "--fail", "http://localhost:8000/health/"] | ||||||
hepheir marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| # Run server | ||||||
| ENTRYPOINT ["bash", "/app/entrypoint.sh"] | ||||||
| CMD ["--bind", "0.0.0.0:8000", "--workers", "4", "--threads", "2"] | ||||||
|
||||||
| CMD ["--bind", "0.0.0.0:8000", "--workers", "4", "--threads", "2"] | |
| CMD ["sh", "-c", "python manage.py migrate && gunicorn app.wsgi:application --bind 0.0.0.0:8000 --workers 4 --threads 2"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
.dockerignorefile includes a typo in the file extension pattern*.py[codz]which should be*.py[cod]. The pattern is meant to ignore compiled Python files (.pyc,.pyo,.pyd), butzis not a valid Python compiled extension.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 패턴은 GitHub에서 공식적으로 제공하는 Python.gitignore 에서 가져온 것입니다. 또한 .gitignore 문법상으로도 유효한 패턴이므로 본 제안은 기각합니다.