Unify dockerfile
This commit is contained in:
parent
92962d4954
commit
c36c18a668
|
@ -0,0 +1,24 @@
|
|||
FROM ubuntu:20.04
|
||||
ENV MODE dev
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install --no-install-recommends -yq \
|
||||
python3 \
|
||||
python3-pip \
|
||||
libpq-dev \
|
||||
gdal-bin \
|
||||
libgdal-dev \
|
||||
make \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . /app
|
||||
RUN pip3 install pipenv
|
||||
RUN sh -c 'if [ "$MODE" = 'production' ]; then pipenv lock --keep-outdated --requirements > requirements.txt; fi'
|
||||
RUN sh -c 'if [ "$MODE" = 'dev' ]; then pipenv lock --dev --requirements > requirements.txt; fi'
|
||||
RUN pip3 install -r requirements.txt
|
||||
RUN python3 -c "import nltk; nltk.download('punkt')"
|
||||
|
||||
RUN sh -c 'if [ -e vas3k_club.env ]; then cp -rf vas3k_club.env /app/club/.env; fi'
|
12
Makefile
12
Makefile
|
@ -12,22 +12,22 @@ run-queue: ## Runs task broker
|
|||
pipenv run python manage.py qcluster
|
||||
|
||||
docker-run-queue:
|
||||
python manage.py qcluster
|
||||
python3 manage.py qcluster
|
||||
|
||||
run-bot: ## Runs telegram bot
|
||||
pipenv run python bot/main.py
|
||||
|
||||
docker-run-bot:
|
||||
python bot/main.py
|
||||
python3 bot/main.py
|
||||
|
||||
run-uvicorn: ## Runs uvicorn (ASGI) server in managed mode
|
||||
pipenv run uvicorn --fd 0 --lifespan off club.asgi:application
|
||||
|
||||
docker-run-dev: ## Runs dev server in docker
|
||||
python ./utils/wait_for_postgres.py
|
||||
python manage.py migrate
|
||||
python manage.py update_tags
|
||||
python manage.py runserver 0.0.0.0:8000
|
||||
python3 ./utils/wait_for_postgres.py
|
||||
python3 manage.py migrate
|
||||
python3 manage.py update_tags
|
||||
python3 manage.py runserver 0.0.0.0:8000
|
||||
|
||||
docker-run-production: ## Runs production server in docker
|
||||
python3 manage.py migrate
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
FROM python:3.8-slim-buster
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get dist-upgrade -y \
|
||||
&& apt-get install --no-install-recommends -yq \
|
||||
gcc \
|
||||
g++ \
|
||||
libc-dev \
|
||||
libpq-dev \
|
||||
gdal-bin \
|
||||
libgdal-dev \
|
||||
make \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# install requirements into a separate layer
|
||||
COPY ./requirements.txt /app/requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY ./dev_requirements.txt /app/dev_requirements.txt
|
||||
RUN pip install -r dev_requirements.txt
|
||||
RUN python -c "import nltk; nltk.download('punkt')"
|
||||
|
||||
# copy the code
|
||||
COPY . /app
|
|
@ -1,12 +0,0 @@
|
|||
FROM node:14-slim
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY ./frontend/package.json ./
|
||||
COPY ./frontend/package-lock.json ./
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY ./frontend ./
|
||||
RUN npm run build
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
-i https://pypi.org/simple
|
||||
asgiref==3.2.10; python_version >= '3.5'
|
||||
attrs==20.1.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
django-debug-toolbar==2.2
|
||||
django==3.1
|
||||
flake8==3.8.3
|
||||
iniconfig==1.0.1
|
||||
mccabe==0.6.1
|
||||
more-itertools==8.4.0; python_version >= '3.5'
|
||||
packaging==20.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pluggy==0.13.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
py==1.9.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pycodestyle==2.6.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pyflakes==2.2.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pytest==6.0.1
|
||||
pytz==2020.1
|
||||
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
sqlparse==0.3.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
toml==0.10.1
|
|
@ -3,11 +3,12 @@ version: "3.7"
|
|||
services:
|
||||
club_app: &app
|
||||
build:
|
||||
dockerfile: production.dockerfile
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
command: make docker-run-production
|
||||
container_name: club_app
|
||||
environment:
|
||||
- MODE=production
|
||||
- PYTHONUNBUFFERED=1
|
||||
- DEBUG=false
|
||||
- APP_HOST=https://vas3k.club
|
||||
|
|
|
@ -3,11 +3,12 @@ version: "3.7"
|
|||
services:
|
||||
tests:
|
||||
build:
|
||||
dockerfile: dev.dockerfile
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
command: make test-ci
|
||||
container_name: tests
|
||||
environment:
|
||||
- MODE=dev
|
||||
- DEBUG=true # regardless of this value django will override it on false
|
||||
- TESTS_RUN=da
|
||||
- PYTHONUNBUFFERED=1
|
||||
|
@ -43,8 +44,8 @@ services:
|
|||
|
||||
webpack:
|
||||
build:
|
||||
dockerfile: dev.frontend.dockerfile
|
||||
context: .
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
command: npm run watch
|
||||
restart: "no"
|
||||
volumes:
|
||||
|
|
|
@ -3,11 +3,12 @@ version: "3.7"
|
|||
services:
|
||||
club_app: &app
|
||||
build:
|
||||
dockerfile: dev.dockerfile
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
command: make docker-run-dev
|
||||
container_name: club_app
|
||||
environment:
|
||||
- MODE=dev
|
||||
- DEBUG=true
|
||||
- PYTHONUNBUFFERED=1
|
||||
- POSTGRES_DB=vas3k_club
|
||||
|
@ -29,10 +30,11 @@ services:
|
|||
|
||||
queue:
|
||||
build:
|
||||
dockerfile: dev.dockerfile
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
command: make docker-run-queue
|
||||
environment:
|
||||
- MODE=dev
|
||||
- DEBUG=true
|
||||
- PYTHONUNBUFFERED=1
|
||||
- POSTGRES_DB=vas3k_club
|
||||
|
@ -50,10 +52,11 @@ services:
|
|||
|
||||
bot:
|
||||
build:
|
||||
dockerfile: dev.dockerfile
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
command: make docker-run-bot
|
||||
environment:
|
||||
- MODE=dev
|
||||
- DEBUG=true
|
||||
- PYTHONUNBUFFERED=1
|
||||
- POSTGRES_DB=vas3k_club
|
||||
|
|
|
@ -17,32 +17,11 @@ Check out our [docker-compose.yml](https://github.com/vas3k/vas3k.club/blob/mast
|
|||
|
||||
Once you decided to code something in the project you'll need to setup your environment. Here's how you can make it.
|
||||
|
||||
### Setup venv
|
||||
### Setup pipenv
|
||||
|
||||
Through `pipenv` // todo: (у меня с ним было 2 проблемы)
|
||||
- сходу не получилось выпилить установку gdal либы (удаление из pipfile и pipfile.locka не помогло), чтобы оно не фейлило установку остальных пакетов
|
||||
- не получилось указать папку созданного из консоли pipenv'а в pycharm'е
|
||||
|
||||
To mitigate gdal build failure (tested on ArchLinux):
|
||||
1. Install gdal on your computer. Version must be same as one in `Pipfile.lock`.
|
||||
Probably you should compile it from sources.
|
||||
2. Run `export CPLUS_INCLUDE_PATH=/usr/include/gdal C_INCLUDE_PATH=/usr/include/gdal`
|
||||
(I am not sure if this is neccessary)
|
||||
3. Then run regular `pipenv install --dev`, it should work fine
|
||||
|
||||
Through old fashion `virtualenv`:
|
||||
- setup your Python Interpreter at PyCharm with `virtualenv`
|
||||
- install deps from [requirements.txt](requirements.txt) and [dev_requirements.txt](dev_requirements.txt)
|
||||
```sh
|
||||
(venv) $ pip install --upgrade -r requirements.txt
|
||||
(venv) $ pip install --upgrade -r dev_requirements.txt
|
||||
```
|
||||
|
||||
If you don't need to work with Geo Data and installation of `gdal` package is failed so skip it with next workaround:
|
||||
```sh
|
||||
# run each line of reqs independently
|
||||
(venv) $ cat requirements.txt | xargs -n 1 pip install
|
||||
```
|
||||
1. Get pipenv: `pip3 install --user pipenv`
|
||||
2. Install packages and activate virtual environment: `pipenv install --dev`
|
||||
3. Check that it was installed correctly: `pipenv shell`
|
||||
|
||||
### Setup postgres
|
||||
|
||||
|
@ -100,11 +79,11 @@ After you have setup postgres, venv and build frontend (look this steps above) c
|
|||
$ docker-compose -f docker-compose.yml up redis
|
||||
|
||||
# run queue
|
||||
(venv) $ ./manage.py qcluster
|
||||
$ pipenv run python manage.py qcluster
|
||||
|
||||
# run db migration
|
||||
(venv) $ ./manage.py migrate
|
||||
$ pipenv run python manage.py migrate
|
||||
|
||||
# run dev server
|
||||
(venv) $ ./manage.py runserver 0.0.0.0:8000
|
||||
$ pipenv run python manage.py runserver 0.0.0.0:8000
|
||||
```
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
FROM node:14-slim
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY . ./
|
||||
|
||||
RUN npm ci
|
||||
RUN npm run build
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
FROM python:3.8-slim-buster
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get dist-upgrade -y \
|
||||
&& apt-get install --no-install-recommends -yq \
|
||||
gcc \
|
||||
g++ \
|
||||
libc-dev \
|
||||
libpq-dev \
|
||||
gdal-bin \
|
||||
libgdal-dev \
|
||||
make \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# install requirements into a separate layer
|
||||
COPY ./requirements.txt /app/requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
RUN python -c "import nltk; nltk.download('punkt')"
|
||||
|
||||
# copy the code
|
||||
COPY . /app
|
||||
COPY ./vas3k_club.env /app/club/.env
|
|
@ -1,74 +0,0 @@
|
|||
#
|
||||
# These requirements were autogenerated by pipenv
|
||||
# To regenerate from the project's Pipfile, run:
|
||||
#
|
||||
# pipenv lock --requirements
|
||||
#
|
||||
|
||||
-i https://pypi.org/simple
|
||||
arrow==1.0.3; python_version >= '3.6'
|
||||
asgiref==3.3.4; python_version >= '3.6'
|
||||
awesome-slugify==1.6.5
|
||||
beautifulsoup4==4.9.3
|
||||
blessed==1.18.0
|
||||
cachetools==4.2.1; python_version ~= '3.5'
|
||||
certifi==2020.12.5
|
||||
cffi==1.14.5
|
||||
chardet==3.0.4
|
||||
click==7.1.2
|
||||
croniter==1.0.10
|
||||
cryptography==2.8
|
||||
cssselect==1.1.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
cssutils==2.2.0; python_version >= '3.6'
|
||||
decorator==5.0.5; python_version >= '3.5'
|
||||
django-picklefield==3.0.1; python_version >= '3'
|
||||
django-q-sentry==0.1.5
|
||||
django-q[sentry]==1.3.5
|
||||
django-redis==4.11.0
|
||||
django-simple-history==2.12.0
|
||||
django-webpack-loader==0.7.0
|
||||
django==3.2
|
||||
feedfinder2==0.0.4
|
||||
feedparser==6.0.2; python_version >= '3.6'
|
||||
filelock==3.0.12
|
||||
future==0.18.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
gunicorn==20.0.4
|
||||
h11==0.12.0; python_version >= '3.6'
|
||||
httptools==0.1.1
|
||||
icalendar==4.0.7
|
||||
idna==2.10; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
jieba3k==0.35.1
|
||||
lxml==4.6.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
mistune==2.0.0a4
|
||||
newspaper3k==0.2.8
|
||||
nltk==3.4.5
|
||||
patreon==0.5.0
|
||||
pillow==8.2.0
|
||||
premailer==3.6.1
|
||||
psycopg2-binary==2.8.4
|
||||
pycparser==2.20; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pyjwt==1.7.1
|
||||
python-dateutil==2.8.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
python-dotenv==0.17.0
|
||||
python-telegram-bot==12.5.1
|
||||
pytz==2021.1
|
||||
pyyaml==5.4.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
|
||||
redis==3.5.3
|
||||
regex==2021.4.4
|
||||
requests-file==1.5.1
|
||||
requests==2.23.0
|
||||
sentry-sdk==1.0.0
|
||||
sgmllib3k==1.0.0
|
||||
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
soupsieve==2.2.1; python_version >= '3'
|
||||
sqlparse==0.4.1; python_version >= '3.5'
|
||||
stripe==2.55.0
|
||||
tinysegmenter==0.3
|
||||
tldextract==3.1.0; python_version >= '3.5'
|
||||
tornado==6.1; python_version >= '3.5'
|
||||
typus==0.2.2
|
||||
unidecode==0.4.21
|
||||
urllib3==1.25.11; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
|
||||
uvicorn==0.13.4
|
||||
uvloop==0.15.2
|
||||
wcwidth==0.2.5
|
Loading…
Reference in New Issue