Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master py3 docker 00 #867

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

martin-bts
Copy link

This is essentially how I have been building and running dockerized Askbot for the past year.

Askbot has a few dependencies which require a compiler, so I moved to a two-staged build, where the first stage builds all required packages, so that the second stage merely installs whl-files and does not need a build environment.

The main image is built in three steps:

  1. Install Askbot using the whl-files from the previous stage.
  2. Create a new Django project for Askbot. This is more or less hard-coded, without using askbot/deployment.
  3. Configure the base image to serve the newly created Django Askbot project.

For a first glimpse, one should be able to simply

docker build -t askbot:latest .
docker run --rm -it -p 8000:8000 askbot:latest

For best results, #864 is applied first. I moved to Python 3.8 a few months ago, but I know 3.7 works just as well. For options see commit message of 8a3f5f3

Martin BTS added 6 commits August 23, 2020 22:56
* provide default for dj_database_url.config()
  sqlite://<PROJECT_ROOT>/askbot.sqlite
* enforce TIMEOUT: 6000
* remove /askbot/ segment from MEDIA_ROOT
* should be deployed into the same dir as settings.py
* current settings.py does reference it.
* .dockerignore improves the build process
* augment_settings.py will be appended to settings.py and is meant to
  provide some degrees of freedom for container creators
* uwsgi.txt is a config snipped we want to use with the (current) base
  image tiangolo/uwsgi-nginx
* build container with docker build -t TAG_YOUR_STUFF .
* docker run TAG_YOUR_STUFF will start an Askbot container using
  locmem and SQLite
* exposes port 8000 by default, change with env var LISTEN_PORT
* use existing database by providing the env var DATABASE_URL, e.g.
  docker run \
  -e DATABASE_URL="postgres://askbot:[email protected]:5432/my_askbot"\
  TAG_YOUR_STUFF -d
* use existing Redis cluster by providing the env vars ASKBOT_CACHE
  and CACHE_NODES, e.g.
  docker run \
  -e ASKBOT_CACHE="redis" -e CACHE_NODES="1.2.3.4:6379,2.3.4.5:6379" \
  TAG_YOUR_STUFF -d
* overwrite admin by providing the env var ADMIN_PASSWORD, e.g.
  docker run \
  -e ADMIN_PASSWORD="supersecret" \
  TAG_YOUR_STUFF -d
* Don't forget to provide your own SECRET_KEY, e.g.
  docker run \
  -e SECRET_KEY="$(openssl rand 14 | base64)" \
  TAG_YOUR_STUFF -d
* To persist staticfiles and upfiles use mounts, e.g.
  docker run \
  --mount type=bind,source=/p/a/th,destination=/askbot-site/static \
  --mount type=bind,source=/p/a/th,destination=/askbot-site/upfiles \
  TAG_YOUR_STUFF -d
# Static files are stored in **/askbot_site/static** . I'd recommend to make it a kubernetes volume.

# Stage 0
FROM tiangolo/uwsgi-nginx:python3.8-alpine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM tiangolo/uwsgi-nginx:python3.8-alpine
FROM tiangolo/uwsgi-nginx:python3.9-alpine

3.8 would be downgrade



# Stage 1
FROM tiangolo/uwsgi-nginx:python3.8-alpine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM tiangolo/uwsgi-nginx:python3.8-alpine
FROM tiangolo/uwsgi-nginx:python3.9-alpine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants