Docker: using Gunicorn (#55)

* docker: using gunicorn
* cleanup

Co-authored-by: CapsLock <github@legeox.net>
This commit is contained in:
TheCapsLock 2021-04-07 22:26:25 +02:00 committed by GitHub
parent f5772d349a
commit ff6bdb0f10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 7 deletions

View file

@ -97,13 +97,17 @@ pip install -e .
### Running in docker ### Running in docker
For this, you need to have [docker](https://docs.docker.com/engine/install/) and [docker-compose](https://docs.docker.com/compose/install/) installed.
To give a try to Copanier quickly, you can use docker: To give a try to Copanier quickly, you can use docker:
```bash ```bash
sudo docker build -t copanier:local . cd docker
sudo docker run --name copanier --rm -p 2244:2244 copanier:local sudo docker-compose -p copanier up
``` ```
The app will be available at http://localhost:2244
## Run local server ## Run local server
Once everything is installed, you can use the `copanier` command to run the server. Once everything is installed, you can use the `copanier` command to run the server.

View file

@ -12,9 +12,7 @@ ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:fr ENV LANGUAGE fr_FR:fr
ENV LC_ALL fr_FR.UTF-8 ENV LC_ALL fr_FR.UTF-8
RUN git clone https://github.com/spiral-project/copanier /srv/copanier COPY ./ /srv/copanier
RUN cd /srv/copanier/ && python3 -m venv venv && . ./venv/bin/activate && pip install wheel && pip install -e . RUN cd /srv/copanier/ && python3 -m venv /srv/copanier-venv && . /srv/copanier-venv/bin/activate && pip install wheel gunicorn && pip install -e .
RUN dpkg-reconfigure locales RUN dpkg-reconfigure locales
RUN sed -i 's/simple_server(app, port=2244)/simple_server(app, host="0.0.0.0", port=2244)/g' /srv/copanier/copanier/__init__.py
ENTRYPOINT ["/srv/copanier/venv/bin/copanier", "serve"]

16
docker/docker-compose.yml Normal file
View file

@ -0,0 +1,16 @@
version: "3.9"
services:
app:
build:
context: ..
dockerfile: "./docker/Dockerfile"
command: /srv/copanier-venv/bin/gunicorn -k roll.worker.Worker copanier:app --bind 0.0.0.0:2244
static:
image: "nginx:latest"
volumes:
- "../copanier/static:/srv/copanier_static/static:ro"
- "./nginx-default.conf:/etc/nginx/conf.d/default.conf:ro"
depends_on:
- app
ports:
- 0.0.0.0:2244:80

13
docker/nginx-default.conf Normal file
View file

@ -0,0 +1,13 @@
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://app:2244;
}
location /static/ {
root /srv/copanier_static/;
index index.html;
}
}