Containerize
This commit is contained in:
parent
783ba5aced
commit
db6dee5d69
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
FROM python:3
|
||||
|
||||
WORKDIR /usr/src/shynet
|
||||
|
||||
RUN pip install pipenv
|
||||
COPY Pipfile.lock ./
|
||||
COPY Pipfile ./
|
||||
RUN pipenv install --system --deploy
|
||||
|
||||
COPY shynet .
|
||||
RUN python manage.py collectstatic --noinput
|
||||
|
||||
ARG GF_UID="500"
|
||||
ARG GF_GID="500"
|
||||
|
||||
# add group & user
|
||||
RUN groupadd -r -g $GF_GID appgroup && \
|
||||
useradd appuser -r -u $GF_UID -g appgroup
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD [ "./webserver.sh" ]
|
2
Pipfile
2
Pipfile
@ -10,6 +10,7 @@ black = "*"
|
||||
django = "*"
|
||||
django-allauth = "*"
|
||||
geoip2 = "*"
|
||||
whitenoise = "*"
|
||||
celery = "*"
|
||||
django-ipware = "*"
|
||||
pyyaml = "*"
|
||||
@ -17,6 +18,7 @@ ua-parser = "*"
|
||||
user-agents = "*"
|
||||
emoji-country-flag = "*"
|
||||
rules = "*"
|
||||
gunicorn = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.6"
|
||||
|
18
Pipfile.lock
generated
18
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "14b7afb8af8c07320e7c765ae013966a5e95dd708a23f056981378beca52846d"
|
||||
"sha256": "c1d7cd1455c79f65e139ba93673e58446c8094311b329be28d44d23fd5510462"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -104,6 +104,14 @@
|
||||
"index": "pypi",
|
||||
"version": "==3.0.0"
|
||||
},
|
||||
"gunicorn": {
|
||||
"hashes": [
|
||||
"sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626",
|
||||
"sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==20.0.4"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
|
||||
@ -228,6 +236,14 @@
|
||||
],
|
||||
"version": "==1.3.0"
|
||||
},
|
||||
"whitenoise": {
|
||||
"hashes": [
|
||||
"sha256:0f9137f74bd95fa54329ace88d8dc695fbe895369a632e35f7a136e003e41d73",
|
||||
"sha256:62556265ec1011bd87113fb81b7516f52688887b7a010ee899ff1fd18fd22700"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==5.0.1"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:aa36550ff0c0b7ef7fa639055d797116ee891440eac1a56f378e2d3179e0320b",
|
||||
|
5
shynet/celeryworker.sh
Executable file
5
shynet/celeryworker.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Start queue worker processes
|
||||
echo Launching Shynet queue worker...
|
||||
exec celery -A shynet worker -E --loglevel=INFO --concurrency=3
|
@ -54,6 +54,7 @@ INSTALLED_APPS = [
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
@ -124,6 +125,9 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
STATIC_URL = "/static/"
|
||||
STATIC_ROOT = "compiledstatic/"
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
|
||||
# Auth
|
||||
|
||||
@ -150,8 +154,7 @@ SITE_ID = 1
|
||||
|
||||
# Celery
|
||||
|
||||
if DEBUG:
|
||||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
|
||||
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
|
||||
CELERY_REDIS_SOCKET_TIMEOUT = 15
|
||||
|
8
shynet/webserver.sh
Executable file
8
shynet/webserver.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Start Gunicorn processes
|
||||
echo Launching Shynet web server...
|
||||
exec gunicorn shynet.wsgi:application \
|
||||
--bind 0.0.0.0:8080 \
|
||||
--workers 3 \
|
||||
--timeout 100
|
Loading…
Reference in New Issue
Block a user