diff --git a/README.md b/README.md index c7f3b16..13dc308 100644 --- a/README.md +++ b/README.md @@ -97,13 +97,17 @@ pip install -e . ### 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: ```bash -sudo docker build -t copanier:local . -sudo docker run --name copanier --rm -p 2244:2244 copanier:local +cd docker +sudo docker-compose -p copanier up ``` +The app will be available at http://localhost:2244 + ## Run local server Once everything is installed, you can use the `copanier` command to run the server. diff --git a/Dockerfile b/docker/Dockerfile similarity index 52% rename from Dockerfile rename to docker/Dockerfile index 4153ee5..44ec0e9 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -12,9 +12,7 @@ ENV LANG fr_FR.UTF-8 ENV LANGUAGE fr_FR:fr ENV LC_ALL fr_FR.UTF-8 -RUN git clone https://github.com/spiral-project/copanier /srv/copanier -RUN cd /srv/copanier/ && python3 -m venv venv && . ./venv/bin/activate && pip install wheel && pip install -e . +COPY ./ /srv/copanier +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 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"] +RUN dpkg-reconfigure locales \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..ddd0f8e --- /dev/null +++ b/docker/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/docker/nginx-default.conf b/docker/nginx-default.conf new file mode 100644 index 0000000..7dee12d --- /dev/null +++ b/docker/nginx-default.conf @@ -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; + } +}