From 1b2dc1d28b14c945805b9baec2f5a7b35b185eeb Mon Sep 17 00:00:00 2001 From: Nikolay Zhuravlev Date: Mon, 6 Nov 2023 01:09:21 +0100 Subject: [PATCH] Docker file cleanup --- .gitignore | 3 +- docker-compose.yml | 26 ----------- docker.env | 5 -- docker/.gitignore | 1 - docker/Dockerfile | 35 -------------- docker/README.md | 12 ----- docker/build-image.sh | 8 ---- docker/db-sync.sh | 3 ++ docker/docker-compose.yml | 80 +++++++++++++++++++++++++++++--- docker/env.app | 11 +++++ docker/env.easyCI2 | 5 ++ docker/env.ipython | 2 + docker/env.mariadb | 1 + docker/env.mysql-db-sync | 10 ++++ docker/env.rb | 7 +++ docker/nginx-app.conf | 95 -------------------------------------- docker/start-uwsgi.sh | 3 -- docker/supervisor-app.conf | 13 ------ docker/update.sh | 7 +++ docker/uwsgi.ini | 30 ------------ docker/uwsgi_params | 16 ------- 21 files changed, 121 insertions(+), 252 deletions(-) delete mode 100644 docker-compose.yml delete mode 100644 docker.env delete mode 100644 docker/.gitignore delete mode 100644 docker/Dockerfile delete mode 100644 docker/README.md delete mode 100755 docker/build-image.sh create mode 100755 docker/db-sync.sh create mode 100644 docker/env.app create mode 100644 docker/env.easyCI2 create mode 100644 docker/env.ipython create mode 100644 docker/env.mariadb create mode 100644 docker/env.mysql-db-sync create mode 100644 docker/env.rb delete mode 100644 docker/nginx-app.conf delete mode 100755 docker/start-uwsgi.sh delete mode 100644 docker/supervisor-app.conf create mode 100755 docker/update.sh delete mode 100644 docker/uwsgi.ini delete mode 100644 docker/uwsgi_params diff --git a/.gitignore b/.gitignore index 839af7eae..9560042b6 100644 --- a/.gitignore +++ b/.gitignore @@ -63,4 +63,5 @@ anytask/media/ .eggs sqlite3.db venv -.idea/ \ No newline at end of file +.idea/ +.vscode/ diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 2b76c6d83..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '3' -services: - backend: - build: . - image: anytask:develop - command: python anytask/manage.py runserver 0.0.0.0:8000 - env_file: docker.env - depends_on: - - postgres - volumes: - - media:/app/media - ports: - - 8000:8000 - - postgres: - image: postgres:9.6 - logging: - driver: none - healthcheck: - test: 'exit 0' - volumes: - - pgdata:/var/lib/postgresql/data - -volumes: - pgdata: - media: \ No newline at end of file diff --git a/docker.env b/docker.env deleted file mode 100644 index a37efc088..000000000 --- a/docker.env +++ /dev/null @@ -1,5 +0,0 @@ -DJANGO_DEBUG=True - -DATABASE_NAME=postgres -DATABASE_USER=postgres -DATABASE_HOST=postgres diff --git a/docker/.gitignore b/docker/.gitignore deleted file mode 100644 index 8fce60300..000000000 --- a/docker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -data/ diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index f7a778acb..000000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM python:2-stretch - -MAINTAINER omrigann@gmail.com - -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -y \ - python \ - python-dev \ - python-pip \ - nginx \ - supervisor \ - && \ - pip2 install pip setuptools && \ - rm -rf /var/lib/apt/lists/* - -# install uwsgi now because it takes a little while -RUN pip install uwsgi - -RUN mkdir /app -COPY ./requirements_local.txt /app/requirements.txt -RUN pip install -r /app/requirements.txt - -# setup all the configfiles -RUN echo "daemon off;" >> /etc/nginx/nginx.conf -COPY docker/nginx-app.conf /etc/nginx/sites-available/default -COPY docker/supervisor-app.conf /etc/supervisor/conf.d/ - -COPY . /app -RUN python /app/anytask/manage.py collectstatic --noinput -RUN python /app/setup.py install - - -EXPOSE 80 -CMD ["supervisord", "-n"] diff --git a/docker/README.md b/docker/README.md deleted file mode 100644 index 84fdb3fbe..000000000 --- a/docker/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Deploying anytask through docker - -``` -cd docker/ -./build-image.sh -docker-compose -up -docker-compose exec web /app/anytask/manage.py createsuperuser -``` - -Anytask will become avalible at `localhost:80` - -Database will be stored in `docker/data/` diff --git a/docker/build-image.sh b/docker/build-image.sh deleted file mode 100755 index 8b100a8c7..000000000 --- a/docker/build-image.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e . -cd $(dirname $0) - -#git pull -git submodule init -git submodule update -docker build -f Dockerfile -t anytask .. diff --git a/docker/db-sync.sh b/docker/db-sync.sh new file mode 100755 index 000000000..ab4c998cd --- /dev/null +++ b/docker/db-sync.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker-compose run mysql-db-sync ./db-sync.sh diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 38ceadf9b..6e34c37b0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,11 +1,77 @@ -version: '3' +version: '2' + services: - web: - image: anytask - environment: - - DJANGO_SETTINGS_MODULE=anytask.settings_docker + app: + env_file: env.app restart: always + image: ghcr.io/znick/anytask:python3.8 + links: + - "mariadb:mariadb" + - "rb_symlink:rb_symlink" ports: - - 80:80 + - "8000:8000" + - "3031:3031" volumes: - - ./data:/app/data + - "/var/lib/anytask/media:/var/lib/anytask/media" + - "/var/log/anytask:/var/log/anytask" + mem_limit: 6GB + ulimits: + nproc: 65535 + nofile: + soft: 40000 + hard: 50000 + ipython: + restart: always + env_file: env.ipython + image: ghcr.io/anytask-org/jupiter_notebook_docker:latest + mem_limit: 600M + ports: + - "5555:5555" + - "8888:8888" + mariadb: + restart: always + env_file: env.mariadb + image: mariadb:10.7.3 + expose: + - "3306" + volumes: + - "/var/lib/anytask/mariadb:/var/lib/mysql" + - "/var/lib/anytask/mariadb_cfg:/etc/mysql/conf.d" + rb: + restart: always + env_file: env.rb + image: ghcr.io/znick/reviewboard:latest + links: + - "mariadb:mariadb" + ports: + - "8181:8000" + volumes: + - "/var/lib/anytask/repos:/var/lib/anytask/repos" + - "/var/lib/anytask/rb:/var/www" + ulimits: + nproc: 65535 + nofile: + soft: 40000 + hard: 50000 + + easyCI2: + restart: always + image: ghcr.io/znick/easyci2:latest + env_file: env.easyCI2 + ports: + - "8001:8000" + - "3032:3031" + + rb_symlink: + restart: always + image: ghcr.io/znick/rb_fake_repo_creator:latest + expose: + - "4444" + volumes: + - "/var/lib/anytask/repos:/var/lib/anytask/repos" + + mysql-db-sync: + image: ghcr.io/znick/mysql-db-sync:latest + env_file: env.mysql-db-sync + links: + - "mariadb:mariadb" diff --git a/docker/env.app b/docker/env.app new file mode 100644 index 000000000..b92681275 --- /dev/null +++ b/docker/env.app @@ -0,0 +1,11 @@ +DATABASE_URL="mysql://anytask:anytask@mariadb/anytask" +DJANGO_MANAGEPY_MIGRATE="on" +RB_API_URL="https://anytask.org/rb" +RB_API_PASSWORD="RB_API_PASSWORD" +RB_SYMLINK_SERVICE_URL="http://rb_symlink:4444" +CONTEST_OAUTH="TOKEN" +CONTEST_OAUTH_ID="TOKEN" +CONTEST_OAUTH_PASSWORD="PASSWORD" +PASSPORT_OAUTH_ID="TOKEN" +PASSPORT_OAUTH_PASSWORD="PASSWORD" +IPYTHON_URL="https://ipython.anytask.org/gate/" diff --git a/docker/env.easyCI2 b/docker/env.easyCI2 new file mode 100644 index 000000000..008d523d5 --- /dev/null +++ b/docker/env.easyCI2 @@ -0,0 +1,5 @@ +GITLAB_REPO_ID="123321" +GITLAB_TRIGGER_TOKEN="TOKEN" +GITLAB_READ_PIPELINES_TOKEN="TOKEN" +GITLAB_WEBHOOKS_TOKEN="TOKEN" +PASSWORDS_JSON='{"https://anytask.org": { "username": "easyci_robot", "password": "PASS"}}' diff --git a/docker/env.ipython b/docker/env.ipython new file mode 100644 index 000000000..7d9b5aae6 --- /dev/null +++ b/docker/env.ipython @@ -0,0 +1,2 @@ +ALLOW_ORIGIN="*" +SALT="SALT" diff --git a/docker/env.mariadb b/docker/env.mariadb new file mode 100644 index 000000000..5662da236 --- /dev/null +++ b/docker/env.mariadb @@ -0,0 +1 @@ +MARIADB_ROOT_PASSWORD="PASS" diff --git a/docker/env.mysql-db-sync b/docker/env.mysql-db-sync new file mode 100644 index 000000000..b352f53bc --- /dev/null +++ b/docker/env.mysql-db-sync @@ -0,0 +1,10 @@ +SRC_USER="root" +SRC_PASS="PASS" +SRC_HOST="mariadb" +SRC_DB="anytask" +SRC_TABLE="auth_user" +DST_USER="root" +DST_PASS="PASS" +DST_HOST="mariadb" +DST_DB="anytask_rb" +DST_TABLE="auth_user" diff --git a/docker/env.rb b/docker/env.rb new file mode 100644 index 000000000..3d0d2ae27 --- /dev/null +++ b/docker/env.rb @@ -0,0 +1,7 @@ +DBHOST="mariadb" +DBTYPE="mysql" +DB="anytask_rb" +DBUSER="anytask_rb" +DBPASSWORD="PASS" +LANG="C.UTF-8" +LC_ALL="C.UTF-8" diff --git a/docker/nginx-app.conf b/docker/nginx-app.conf deleted file mode 100644 index 02f3b6be8..000000000 --- a/docker/nginx-app.conf +++ /dev/null @@ -1,95 +0,0 @@ -# nginx-app.conf - -# the upstream component nginx needs to connect to -server { - server_name "~^www\.(.*)$" ; - return 301 $scheme://$1$request_uri ; -} - -upstream django { - server unix:/app/docker/app.sock; # for a file socket - # server 127.0.0.1:8001; # for a web port socket (we'll use this first) -} - - -access_log /dev/stdout; -error_log /dev/stdout; - -# configuration of the server -server { - # the port your site will be served on, default_server indicates that this server block - # is the block to use if no blocks match the server_name - listen 80 default_server; - - resolver 127.0.0.11; - - # the domain name it will serve for - server_name localhost; # substitute your machine's IP address or FQDN - charset utf-8; - - # max upload size - client_max_body_size 75M; # adjust to taste - - location ~* (?:animated_line\.min\.js|logo_animation\.min\.js|ubuntu\.css)$ { - expires 1M; - access_log off; - add_header Cache-Control "public"; - } - - # Django media - location /media/ { - alias /app/anytask/media/; # your Django project's media files - amend as required - } - - location /static/ { - alias /app/anytask/static/; # your Django project's static files - amend as required - } - - - location ^~/robots.txt { - alias /app/anytask/static/robots.txt; - } - - - location =/sitemap.xml { - alias /app/anytask/static/sitemap.xml; - } - - # Finally, send all non-media requests to the Django server. - location / { - uwsgi_pass django; - include /app/docker/uwsgi_params; # the uwsgi_params file you installed - } - - # gzip some text files - # TODO: think about caching / static gzip - gzip on; - gzip_comp_level 5; - gzip_min_length 256; - gzip_proxied any; - gzip_types - application/atom+xml - application/javascript - application/json - application/ld+json - application/manifest+json - application/rss+xml - application/vnd.geo+json - application/vnd.ms-fontobject - application/x-font-ttf - application/x-web-app-manifest+json - application/xhtml+xml - application/xml - font/opentype - image/bmp - image/svg+xml - image/x-icon - text/cache-manifest - text/css - text/plain - text/vcard - text/vnd.rim.location.xloc - text/vtt - text/x-component - text/x-cross-domain-policy; -} diff --git a/docker/start-uwsgi.sh b/docker/start-uwsgi.sh deleted file mode 100755 index 237d28b46..000000000 --- a/docker/start-uwsgi.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -/app/anytask/manage.py syncdb --migrate --noinput -/usr/local/bin/uwsgi --ini /app/docker/uwsgi.ini diff --git a/docker/supervisor-app.conf b/docker/supervisor-app.conf deleted file mode 100644 index e73efaa5d..000000000 --- a/docker/supervisor-app.conf +++ /dev/null @@ -1,13 +0,0 @@ -[program:app-uwsgi] -command = /app/docker/start-uwsgi.sh -stdout_logfile = /dev/stdout -stderr_logfile = /dev/stderr -stdout_logfile_maxbytes = 0 -stderr_logfile_maxbytes = 0 - -[program:nginx-app] -command = /usr/sbin/nginx -stdout_logfile = /dev/stdout -stderr_logfile = /dev/stderr -stdout_logfile_maxbytes = 0 -stderr_logfile_maxbytes = 0 diff --git a/docker/update.sh b/docker/update.sh new file mode 100755 index 000000000..4cd38d05a --- /dev/null +++ b/docker/update.sh @@ -0,0 +1,7 @@ +#!/bin/bash -x + +date +docker compose pull +docker compose up -d +echo Done! +date diff --git a/docker/uwsgi.ini b/docker/uwsgi.ini deleted file mode 100644 index b6e786fab..000000000 --- a/docker/uwsgi.ini +++ /dev/null @@ -1,30 +0,0 @@ -[uwsgi] -# this config will be loaded if nothing specific is specified -# load base config from below -ini = :base -pythonpath = /app/anytask - -# %d is the dir this configuration file is in -socket = %dapp.sock -master = true -processes = 4 - -[dev] -ini = :base -# socket (uwsgi) is not the same as http, nor http-socket -socket = :8001 - - -[local] -ini = :base -http = :8000 - - -[base] -# chdir to the folder with wsgi.py -chdir = /app -# load the module from wsgi.py, it is a python path from -# the directory above. -module=anytask.wsgi:application -# allow anyone to connect to the socket. This is very permissive -chmod-socket=666 diff --git a/docker/uwsgi_params b/docker/uwsgi_params deleted file mode 100644 index f539451b6..000000000 --- a/docker/uwsgi_params +++ /dev/null @@ -1,16 +0,0 @@ - -uwsgi_param QUERY_STRING $query_string; -uwsgi_param REQUEST_METHOD $request_method; -uwsgi_param CONTENT_TYPE $content_type; -uwsgi_param CONTENT_LENGTH $content_length; - -uwsgi_param REQUEST_URI $request_uri; -uwsgi_param PATH_INFO $document_uri; -uwsgi_param DOCUMENT_ROOT $document_root; -uwsgi_param SERVER_PROTOCOL $server_protocol; -uwsgi_param HTTPS $https if_not_empty; - -uwsgi_param REMOTE_ADDR $remote_addr; -uwsgi_param REMOTE_PORT $remote_port; -uwsgi_param SERVER_PORT $server_port; -uwsgi_param SERVER_NAME $server_name;