lots of docker nitpicks
- changed all service names to not include "forget", let docker-compose generate container names - gave the image a single name - listen on 127.0.0.1 by default, provide documented override file that reverses it - docs: on that note: don't tell folks to edit docker-compose.yml directly - docs: explicitly say "run docker-compose build" because docker-compose is janky and it can be surprising that downloading a new version of the code and running `docker-compose up` doesn't do anything
This commit is contained in:
parent
fddcbbe8a0
commit
30b7b24e68
|
@ -18,8 +18,5 @@ config.example.py
|
|||
config.docker.py
|
||||
forget.example.service
|
||||
requirements-dev.txt
|
||||
|
||||
redis
|
||||
postgres
|
||||
celery
|
||||
data
|
||||
config.py
|
||||
|
|
|
@ -9,7 +9,7 @@ static/*
|
|||
.coverage
|
||||
.pytest_cache
|
||||
|
||||
# docker stuff
|
||||
/redis
|
||||
/postgres
|
||||
/celery
|
||||
data/*
|
||||
!data/.keep
|
||||
|
||||
docker-compose.override.yml
|
||||
|
|
|
@ -29,4 +29,6 @@ FROM deps
|
|||
COPY --from=layer-cake / ./
|
||||
RUN doit
|
||||
|
||||
ENV FLASK_APP=forget.py
|
||||
|
||||
VOLUME ["/var/run/celery"]
|
||||
|
|
|
@ -120,30 +120,21 @@ server will be started and shut down automatically by the test suite.
|
|||
|
||||
This project is also able to be deployed through Docker.
|
||||
|
||||
1. Copy `docker-compose.yml` and `config.docker.py` into your preferred
|
||||
directory.
|
||||
1. Rename `config.docker.py` to `config.py` and add additional configurations to
|
||||
1. Copy `config.docker.py` to `config.py` and add additional configurations to
|
||||
your liking.
|
||||
1. By default, the webapp container will be listening on `127.0.0.1:42157`,
|
||||
which you can point a reverse proxy at.
|
||||
* If your reverse proxy is in another docker network then you'll need a
|
||||
`docker-compose.override.yml` file to attach the `www` service to the
|
||||
right network and not publish any ports. An example override file is
|
||||
provided. The web app will be listening on `http://forget-www-1:42157`.
|
||||
1. By default, the `docker-compose.yml` creates relative mounts `./redis`,
|
||||
`./postgres`, and `./celery` relative to the `docker-compose.yml` location.
|
||||
Feel free to change these if you'd like.
|
||||
An example `docker-compose.override.yml` file is provided that shows how to
|
||||
change this.
|
||||
1. Run `docker-compose build` to build the image.
|
||||
1. Run `docker-compose up` to start or `docker-compose up -d` to start in the
|
||||
background, and use `docker-compose down` to stop.
|
||||
1. If you have a reverse proxy on a Docker network already, simply add the
|
||||
Docker network details to `docker-compose.yml` and Forget should be available
|
||||
at `http://forget:42157` in the Docker network. Otherwise, you'll need to add
|
||||
something like the following to bind the Docker container to a port:
|
||||
```
|
||||
services:
|
||||
forget:
|
||||
...lots of stuff...
|
||||
ports:
|
||||
- "127.0.0.1:42157:42157"
|
||||
...other stuff...
|
||||
```
|
||||
This will bind the container's port `42157` to `127.0.0.1:42157` on your
|
||||
local machine, which you can then reverse proxy. Make sure to never expose
|
||||
this publically, as it is http and not secure!
|
||||
|
||||
## Contact
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ determines where to connect to the database
|
|||
see <http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls> for syntax
|
||||
only postgresql with psycopg2 driver is officially supported
|
||||
"""
|
||||
SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://postgres:postgres@forget-db/forget'
|
||||
SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://postgres:postgres@db/forget'
|
||||
|
||||
"""
|
||||
REDIS URI
|
||||
|
@ -22,7 +22,7 @@ REDIS URI
|
|||
see <https://redis-py.readthedocs.io/en/latest/#redis.ConnectionPool.from_url>
|
||||
for syntax reference
|
||||
"""
|
||||
REDIS_URI='redis://forget-redis'
|
||||
REDIS_URI='redis://redis'
|
||||
|
||||
"""
|
||||
SERVER ADDRESS
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
## uncomment below and change network name to use a reverse proxy on an
|
||||
## existing network
|
||||
#networks:
|
||||
# mycoolreverseproxynetwork:
|
||||
# external: true
|
||||
|
||||
services:
|
||||
www:
|
||||
## uncomment below to stop listening on 127.0.0.1
|
||||
# ports: []
|
||||
|
||||
networks:
|
||||
- forget
|
||||
## uncomment below and change network name to use a reverse proxy on an
|
||||
## existing network
|
||||
# - mycoolreverseproxynetwork
|
||||
|
||||
|
||||
## if you wish to change where postgres, redis, and celery persistent data is
|
||||
## stored, uncomment below and change the first part of each volume (before the `:`)
|
||||
|
||||
# redis:
|
||||
# volumes:
|
||||
# - /my/cool/redis/path:/data
|
||||
# db:
|
||||
# volumes:
|
||||
# - /my/cool/postgres/path:/var/lib/postgresql/data
|
||||
# worker:
|
||||
# volumes:
|
||||
# - /my/cool/celery/path:/var/run/celery
|
||||
# beat:
|
||||
# volumes:
|
||||
# - /my/cool/celery/path:/var/run/celery
|
|
@ -1,40 +1,48 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
forget:
|
||||
www:
|
||||
build:
|
||||
context: ./
|
||||
container_name: forget
|
||||
image: codl/forget
|
||||
pull_policy: build
|
||||
restart: always
|
||||
environment:
|
||||
- FLASK_APP=forget.py
|
||||
volumes:
|
||||
- ./config.py:/usr/src/app/config.py
|
||||
- type: bind
|
||||
source: ./config.py
|
||||
target: /usr/src/app/config.py
|
||||
read_only: true
|
||||
depends_on:
|
||||
- forget-redis
|
||||
- forget-db
|
||||
- forget-worker
|
||||
- forget-beat
|
||||
- redis
|
||||
- db
|
||||
- worker
|
||||
- beat
|
||||
command: bash -c "
|
||||
flask db upgrade &&
|
||||
gunicorn -w 9 -t 3600 -b 0.0.0.0:42157 forget:app
|
||||
"
|
||||
networks:
|
||||
- forget
|
||||
expose:
|
||||
- 42157
|
||||
ports:
|
||||
- "127.0.0.1:42157:42157"
|
||||
|
||||
forget-worker:
|
||||
worker:
|
||||
build:
|
||||
context: ./
|
||||
container_name: forget-worker
|
||||
image: codl/forget
|
||||
pull_policy: build
|
||||
restart: always
|
||||
environment:
|
||||
- FLASK_APP=forget.py
|
||||
volumes:
|
||||
- ./config.py:/usr/src/app/config.py
|
||||
- ./celery/run:/var/run/celery
|
||||
- type: bind
|
||||
source: ./config.py
|
||||
target: /usr/src/app/config.py
|
||||
read_only: true
|
||||
- ./data/celery/run:/var/run/celery
|
||||
depends_on:
|
||||
- forget-redis
|
||||
- forget-db
|
||||
- redis
|
||||
- db
|
||||
networks:
|
||||
- forget
|
||||
command: bash -c "
|
||||
mkdir -p /var/run/celery &&
|
||||
chown -R nobody:nogroup /var/run/celery &&
|
||||
|
@ -45,19 +53,23 @@ services:
|
|||
--uid=nobody --gid=nogroup
|
||||
"
|
||||
|
||||
forget-beat:
|
||||
beat:
|
||||
build:
|
||||
context: ./
|
||||
container_name: forget-beat
|
||||
image: codl/forget
|
||||
pull_policy: build
|
||||
restart: always
|
||||
environment:
|
||||
- FLASK_APP=forget.py
|
||||
volumes:
|
||||
- ./config.py:/usr/src/app/config.py
|
||||
- ./celery/run:/var/run/celery
|
||||
- type: bind
|
||||
source: ./config.py
|
||||
target: /usr/src/app/config.py
|
||||
read_only: true
|
||||
- ./data/celery/run:/var/run/celery
|
||||
depends_on:
|
||||
- forget-redis
|
||||
- forget-db
|
||||
- redis
|
||||
- db
|
||||
networks:
|
||||
- forget
|
||||
command: bash -c "
|
||||
mkdir -p /var/run/celery &&
|
||||
chown -R nobody:nogroup /var/run/celery &&
|
||||
|
@ -67,20 +79,25 @@ services:
|
|||
--uid=nobody --gid=nogroup
|
||||
"
|
||||
|
||||
forget-redis:
|
||||
container_name: forget-redis
|
||||
redis:
|
||||
image: redis:4.0-alpine
|
||||
restart: always
|
||||
volumes:
|
||||
- ./redis:/data
|
||||
- ./data/redis:/data
|
||||
networks:
|
||||
- forget
|
||||
|
||||
forget-db:
|
||||
db:
|
||||
image: postgres:14-alpine
|
||||
container_name: forget-db
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=forget
|
||||
volumes:
|
||||
- ./postgres:/var/lib/postgresql/data
|
||||
- ./data/postgres:/var/lib/postgresql/data
|
||||
networks:
|
||||
- forget
|
||||
|
||||
networks:
|
||||
forget:
|
||||
|
|
Loading…
Reference in New Issue