Browse Source

added Docker

devel
Dmitry Novikov 3 years ago
parent
commit
557b8224ee
  1. 12
      .dockerignore
  2. 32
      Dockerfile
  3. 4
      djing/local_settings.py.example
  4. 4
      djing/settings.py
  5. 30
      docker-compose.yml
  6. 16
      requirements.txt
  7. 15
      update_release.sh

12
.dockerignore

@ -0,0 +1,12 @@
*.pyc
*.db
media/*
media/min/*
.idea/
.git/
gmap/fixtures
*.sqlite3
*.json
*.bak
*.mo
venv/

32
Dockerfile

@ -0,0 +1,32 @@
FROM python:3.9-alpine
LABEL maintainer="nerosketch@gmail.com"
ENV PYTHONUNBUFFERED 1
ENV PYTHONOPTIMIZE 1
ENV PYTHONIOENCODING UTF-8
ENV DJANGO_SETTINGS_MODULE djing.settings
ENV PYCURL_SSL_LIBRARY openssl
RUN ["apk", "add", "net-snmp-dev", "arping", "gettext", "inetutils-telnet", "musl-dev", "libffi-dev", "libpq-dev", "make", "gcc", "curl-dev", "libjpeg-turbo-dev", "zlib-dev", "expect", "python3-dev", "mariadb-dev", "--no-cache"]
RUN ["adduser", "-G", "www-data", "-SDH", "-h", "/var/www/djing2", "www-data"]
RUN mkdir -p /var/www/djing/media && chown -R www-data. /var/www/djing
COPY --chown=www-data:www-data ["requirements.txt", "/var/www/djing"]
RUN ["pip", "install", "--no-cache-dir", "--upgrade", "-r", "/var/www/djing/requirements.txt"]
EXPOSE 8000
VOLUME /var/www/djing/media
VOLUME /var/www/djing/static
COPY --chown=www-data:www-data [".", "/var/www/djing/"]
COPY --chown=www-data:www-data ["djing/local_settings.py.example", "/var/www/djing/djing/local_settings.py"]
WORKDIR /var/www/djing
USER www-data
#RUN ["./manage.py", "collectstatic", "--no-input", "--link"]
CMD ./manage.py migrate && \
./manage.py compilemessages && \
exec gunicorn --bind 0.0.0.0:8000 --workers 15 djing.wsgi:application

4
djing/local_settings.py.example

@ -21,9 +21,9 @@ DATABASES = {
},
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djing_db',
'USER': 'djinguser', # You can change the user name
'USER': 'root', # You can change the user name
'PASSWORD': 'password', # You can change the password
'HOST': 'localhost',
'HOST': 'db',
'TEST': {
'CHARSET': 'utf8',
'COLLATION': 'utf8_general_ci'

4
djing/settings.py

@ -170,9 +170,9 @@ SESSION_COOKIE_AGE = 60 * 60 * 24
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = '/static/'
if DEBUG:
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
# Example output: 16 september 2018
DATE_FORMAT = 'd E Y'

30
docker-compose.yml

@ -0,0 +1,30 @@
version: '3.5'
services:
db:
image: mariadb
restart: always
environment:
- MARIADB_ROOT_PASSWORD=password
- MARIADB_DATABASE=djing_db
- MARIADB_INITDB_SKIP_TZINFO=y
volumes:
- db-data:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
app:
image: nerosketch/djing:latest
depends_on:
- db
stdin_open: true
tty: true
tmpfs:
- /tmp
volumes:
- media-data:/var/www/djing/media
- /etc/localtime:/etc/localtime:ro
ports:
- 8000:8000
volumes:
db-data:
media-data:
nginx_logs:

16
requirements.txt

@ -12,14 +12,13 @@ dicttoxml==1.7.4
# db client for Mariadb
mysqlclient
git+git://github.com/nerosketch/easysnmp.git#egg=easysnmp
https://github.com/nerosketch/easysnmp/archive/refs/tags/0.2.5.zip#egg=easysnmp
pid==3.0.4
django-guardian==2.3.0
pinax-theme-bootstrap==8.0.1
django-bootstrap3==14.1.0
# django-jsonfield
-e git://github.com/dmkoch/django-jsonfield.git#egg=django-jsonfield
jsonfield
requests==2.24.0
webdavclient==1.0.8
@ -27,22 +26,23 @@ transliterate==1.10.2
django-encrypted-model-fields==0.5.8
# django-xmlview for pay system allpay
-e git://github.com/nerosketch/django-xmlview.git#egg=django-xmlview
https://github.com/nerosketch/django-xmlview/archive/refs/tags/v0.0.2.zip#egg=django-xmlview
# django-bitfield
-e git://github.com/disqus/django-bitfield.git#egg=django-bitfield
https://github.com/disqus/django-bitfield/archive/refs/tags/2.2.0.zip#egg=django-bitfield
# django_cleanup for clean unused media
-e git://github.com/un1t/django-cleanup.git#egg=django_cleanup
https://github.com/un1t/django-cleanup/archive/refs/tags/6.0.0.zip#egg=django_cleanup
# viberbot
-e git://github.com/Viber/viber-bot-python.git#egg=viberbot
https://github.com/Viber/viber-bot-python/archive/refs/tags/1.0.11.zip#egg=viberbot
# pexpect
-e git://github.com/pexpect/pexpect.git#egg=pexpect
https://github.com/pexpect/pexpect/archive/refs/tags/4.8.0.zip#egg=pexpect
Celery
redis==3.5.3
celery[redis]
docxtpl
gunicorn

15
update_release.sh

@ -0,0 +1,15 @@
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
dock=$(which docker)
if [ $? -eq 1 ]; then
echo "docker not found. Check if it is installed."
exit 1
fi
docker build -t djing:latest .
docker tag djing:latest nerosketch/djing:latest
docker push nerosketch/djing:latest
docker rmi djing:latest
Loading…
Cancel
Save