mirror of https://codeberg.org/dribdat/dribdat.git
Add docker files / notes
This commit is contained in:
parent
f8c326c96e
commit
6ed35925e4
|
@ -0,0 +1,25 @@
|
|||
**/__pycache__
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
README.md
|
|
@ -57,6 +57,7 @@ docs/_build
|
|||
# Virtualenvs and utility scripts
|
||||
env/
|
||||
debug.sh
|
||||
.db/
|
||||
|
||||
# JavaScript
|
||||
node_modules
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# For more information, please refer to https://aka.ms/vscode-docker-python
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
# Install compiler
|
||||
RUN apt-get update && apt-get install gcc -y && apt-get clean
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
# Keeps Python from generating .pyc files in the container
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Turns off buffering for easier container logging
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Install pip requirements
|
||||
COPY requirements.txt .
|
||||
COPY requirements/* requirements/
|
||||
RUN python -m pip install -r requirements.txt
|
||||
|
||||
# Copy dribdat app
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
|
||||
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
|
||||
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
|
||||
USER appuser
|
||||
|
||||
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
|
||||
CMD gunicorn --bind 0.0.0.0:5000 dribdat.app:init_app\(\)
|
25
README.md
25
README.md
|
@ -15,12 +15,31 @@ _Screenshot of a dribdat event page._
|
|||
|
||||
# Quickstart
|
||||
|
||||
This project can be deployed to any server capable of serving Python applications, and is set up for fast deployment to the [Heroku](http://heroku.com) cloud:
|
||||
This project can be deployed to any server capable of serving Python applications, and is set up for fast deployment using Docker or to the [Heroku](http://heroku.com) cloud:
|
||||
|
||||
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
|
||||
|
||||
The first user that registers becomes an admin, so don't delay! If you would like to run dribdat on any other cloud or local machine, follow the [Developer guide](#developer-guide) below. The following section details environment variables you can add to tweak your installation.
|
||||
|
||||
## Docker
|
||||
|
||||
To deploy dribdat using Docker, use the included [docker-compose.yml file](docker-compose.yml) as a starting point and launch `docker-compose up -d`. By default, it persists the database files on the local filesystem, outside the container.
|
||||
|
||||
For a first-time setup, perform the initial migrations from an interactive bash session inside a container:
|
||||
|
||||
```
|
||||
docker-compose run --rm dribdat /bin/bash
|
||||
```
|
||||
|
||||
And once in bash:
|
||||
|
||||
```
|
||||
mv migrations migrations_prod
|
||||
python manage.py db init
|
||||
python manage.py db migrate
|
||||
python manage.py db upgrade
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Optimize your dribdat instance with the following environment variables in production:
|
||||
|
@ -151,7 +170,9 @@ This section has some advice for developers and operators.
|
|||
|
||||
### Shell access
|
||||
|
||||
To open the interactive shell, run: `python manage.py shell` (or, using the [Heroku toolchain](https://devcenter.heroku.com/categories/command-line), `heroku run python manage.py shell`). By default, you will have access to the `User` model, as well as Event, Project, Category, Activity.
|
||||
To open the interactive shell, run: `python manage.py shell`. By default, you will have access to the `User` model, as well as Event, Project, Category, Activity.
|
||||
|
||||
Using the [Heroku toolchain](https://devcenter.heroku.com/categories/command-line), `heroku run python manage.py shell`, or using [Docker](https://www.docker.com/), `docker-compose run --rm dribdat python manage.py shell`.
|
||||
|
||||
### Running Tests
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
version: '3.4'
|
||||
|
||||
services:
|
||||
dribdat:
|
||||
image: dribdat
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
ports:
|
||||
- 5000:5000
|
||||
environment:
|
||||
# - SERVER_URL=hack.opendata.ch
|
||||
- DATABASE_URL=postgres://dribdat_user:changeme@db:5432/dribdat
|
||||
- DRIBDAT_ENV=prod
|
||||
- DRIBDAT_SECRET=changeme
|
||||
- DRIBDAT_APIKEY=changeme
|
||||
- TIME_ZONE=Europe/Zurich
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
image: postgres
|
||||
volumes:
|
||||
- ./.db:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=dribdat
|
||||
- POSTGRES_USER=dribdat_user
|
||||
- POSTGRES_PASSWORD=changeme
|
Loading…
Reference in New Issue