Skip to content

Commit 062ad4b

Browse files
committed
[NEW] Add containerization
1 parent 6818d55 commit 062ad4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+227
-44
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
.git
3+
.gitignore

.gitignore

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,25 @@ ipython_config.py
9797
# pyenv
9898
# For a library or package, you might want to ignore these files since the code is
9999
# intended to run in multiple environments; otherwise, check them in:
100-
# .python-version
100+
.python-version
101101

102102
# pipenv
103103
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104104
# However, in case of collaboration, if having platform-specific dependencies or dependencies
105105
# having no cross-platform support, pipenv may install dependencies that don't work, or not
106106
# install all needed dependencies.
107-
#Pipfile.lock
107+
Pipfile.lock
108108

109109
# poetry
110110
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
111111
# This is especially recommended for binary packages to ensure reproducibility, and is more
112112
# commonly ignored for libraries.
113113
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
114-
#poetry.lock
114+
poetry.lock
115115

116116
# pdm
117117
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118-
#pdm.lock
118+
pdm.lock
119119
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
120120
# in version control.
121121
# https://pdm.fming.dev/#use-with-ide
@@ -169,6 +169,12 @@ cython_debug/
169169
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
170170
# and can be added to the global gitignore or merged into this file. For a more nuclear
171171
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
172-
#.idea/
172+
.idea/
173+
174+
# VSCode
175+
.vscode/
176+
177+
# Local files to ignore
178+
ignored/
173179

174180
# End of https://www.toptal.com/developers/gitignore/api/django

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.12.6-slim-bookworm
2+
ENV PYTHONDONTWRITEBYTECODE=1
3+
ENV PYTHONUNBUFFERED=1
4+
5+
ENV APP_HOME=/home/roback
6+
WORKDIR $APP_HOME
7+
8+
# Install libmagic for python-magic library
9+
RUN apt-get update && apt-get install -y libmagic1
10+
11+
COPY requirements.txt $APP_HOME/requirements.txt
12+
13+
RUN pip install --no-cache-dir -r $APP_HOME/requirements.txt
14+
15+
COPY ./src $APP_HOME/src
16+
COPY ./entrypoint.sh $APP_HOME/entrypoint.sh
17+
18+
EXPOSE 8000
19+
20+
ENTRYPOINT $APP_HOME/entrypoint.sh

entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "${0}: Running migrations"
6+
python3 src/manage.py flush --no-input
7+
python3 src/manage.py makemigrations --merge
8+
python3 src/manage.py migrate --noinput
9+
10+
echo "${0}: Populating seed data"
11+
python3 src/manage.py seeder
12+
13+
echo "${0}: Running server"
14+
python3 src/manage.py runserver 0.0.0.0:8000

requirements.txt

188 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

roback/roback/asgi.py renamed to src/roback/asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
ASGI config for roback project.
2+
ASGI config for src project.
33
44
It exposes the ASGI callable as a module-level variable named ``application``.
55

roback/roback/settings.py renamed to src/roback/settings.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Django settings for roback project.
2+
Django settings for src project.
33
44
Generated by 'django-admin startproject' using Django 4.2.6.
55
@@ -21,12 +21,15 @@
2121
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
2222

2323
# SECURITY WARNING: keep the secret key used in production secret!
24-
SECRET_KEY = 'django-insecure-x$8-h85lyj72^%^frj_8k^h(lmow7d_8bo7bjx%dkn@*j-x4%x'
24+
SECRET_KEY = os.environ["SECRET_KEY"]
2525

2626
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = True
27+
DEBUG = bool(os.environ.get("DEBUG", default=0))
2828

29-
ALLOWED_HOSTS = []
29+
ALLOWED_HOSTS = [
30+
"localhost",
31+
"127.0.0.1",
32+
]
3033

3134

3235
# Application definition
@@ -77,11 +80,14 @@
7780

7881
# Database
7982
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
80-
8183
DATABASES = {
8284
'default': {
83-
'ENGINE': 'django.db.backends.sqlite3',
84-
'NAME': BASE_DIR / 'db.sqlite3',
85+
'ENGINE': os.environ.get("ENGINE", ""),
86+
'NAME': os.environ.get("NAME", ""),
87+
'USER': os.environ.get("USER", ""),
88+
'PASSWORD': os.environ.get("PASSWORD", ""),
89+
'HOST': os.environ.get("HOST", ""),
90+
'PORT': os.environ.get("PORT", ""),
8591
}
8692
}
8793

@@ -133,11 +139,9 @@
133139
'PAGE_SIZE': 20
134140
}
135141

136-
137-
138142
# Custom media URL
139143
MEDIA_URL = os.environ["MEDIA_URL"]
140-
MEDIA_ROOT = Path(BASE_DIR, MEDIA_URL)
144+
MEDIA_ROOT = os.environ["MEDIA_ROOT"]
141145

142146
# Accepted extensions for file uploads
143147
ACCEPTED_MIME_TYPES = {

roback/roback/urls.py renamed to src/roback/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
URL configuration for roback project.
2+
URL configuration for src project.
33
44
The `urlpatterns` list routes URLs to views. For more information please see:
55
https://docs.djangoproject.com/en/4.2/topics/http/urls/

0 commit comments

Comments
 (0)