feat: dockerize app
This commit is contained in:
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
./venv
|
||||
./db/db.sqlite3
|
0
.github/workflows/build.yaml
vendored
Normal file
0
.github/workflows/build.yaml
vendored
Normal file
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
FROM python:3.10-alpine
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
ADD requirements.txt /opt/requirements.txt
|
||||
|
||||
RUN set -ex \
|
||||
&& apk add --no-cache --virtual .build-deps postgresql-dev build-base \
|
||||
jpeg-dev zlib-dev libjpeg libxml2-dev libxslt-dev \
|
||||
&& pip install --upgrade pip \
|
||||
&& pip install --no-cache-dir -r /opt/requirements.txt \
|
||||
&& runDeps="$(scanelf --needed --nobanner --recursive /env \
|
||||
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
|
||||
| sort -u \
|
||||
| xargs -r apk info --installed \
|
||||
| sort -u)" \
|
||||
&& apk add --virtual rundeps $runDeps \
|
||||
&& apk del .build-deps
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["./start.sh"]
|
||||
|
||||
ADD . /opt
|
||||
RUN chmod 755 /opt/start.sh
|
@ -23,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
SECRET_KEY = os.getenv('SECRET', 'django-insecure-c%g@wujt4dco#e%k-!25o3)0%t+wm5=k%l(m!kk^p_g%kknod!')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = os.getenv('DEBUG', 'False')
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
@ -45,6 +45,7 @@ INSTALLED_APPS = [
|
||||
MIDDLEWARE = [
|
||||
# 'later42.logging.debug.ExceptionLoggingMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@ -84,6 +85,17 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
if os.getenv('DB_TYPE') == 'postgres':
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'NAME': os.environ.get('DB_NAME'),
|
||||
'USER': os.environ.get('DB_USER'),
|
||||
'PASSWORD': os.environ.get('DB_PASS'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
||||
@ -123,6 +135,9 @@ STATIC_URL = 'static/'
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "later42/static",
|
||||
]
|
||||
STATIC_ROOT = BASE_DIR / "static"
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||
|
||||
|
BIN
later42/static/apps/later42.shortcut
Normal file
BIN
later42/static/apps/later42.shortcut
Normal file
Binary file not shown.
@ -43,7 +43,6 @@ urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('signup/', signup.register, name='signup'),
|
||||
path("accounts/login/", LoginView.as_view(authentication_form=CustomLoginForm), name="login"),
|
||||
path('accounts/', include('django_registration.backends.activation.urls')),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path('profile/', profile.get, name='profile'),
|
||||
path('api/url/', api.URL.as_view(), name='urls'),
|
||||
|
@ -4,3 +4,4 @@ loguru==0.6.0
|
||||
bs4==0.0.1
|
||||
requests==2.28.1
|
||||
djangorestframework==3.14.0
|
||||
whitenoise==6.2.0
|
||||
|
4
start.sh
Normal file
4
start.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
./manage.py migrate --noinput
|
||||
exec gunicorn --bind :8000 --workers 4 later42.wsgi:application
|
0
static/.keep
Normal file
0
static/.keep
Normal file
Reference in New Issue
Block a user