mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Add Docker support #48
This commit is contained in:
parent
0200249fdc
commit
6fad6534de
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
**/__pycache__
|
||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
README.md
|
||||||
32
.github/workflows/docker.yml
vendored
Normal file
32
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: danielgrams/gsevpt:latest
|
||||||
|
-
|
||||||
|
name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM python:3.7-slim-buster
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
# Turns off buffering for easier container logging
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Install pip requirements
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN python -m pip install -r requirements.txt
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN chmod u+x ./entrypoint.sh
|
||||||
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://travis-ci.com/DanielGrams/gsevpt) [](https://coveralls.io/github/DanielGrams/gsevpt?branch=master) [](https://github.com/psf/black) [](https://pyup.io/repos/github/DanielGrams/gsevpt/)
|
[](https://travis-ci.com/DanielGrams/gsevpt) [](https://coveralls.io/github/DanielGrams/gsevpt?branch=master) [](https://github.com/psf/black) [](https://pyup.io/repos/github/DanielGrams/gsevpt/)
|
||||||
|
|
||||||
Website prototype using Python, Flask and Postgres running on Heroku.
|
Website prototype using Python, Flask and Postgres.
|
||||||
|
|
||||||
## Automatic Deployment
|
## Automatic Deployment
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ psql -c 'create database gsevpt;' -U postgres
|
|||||||
export DATABASE_URL="postgresql://postgres@localhost/gsevpt"
|
export DATABASE_URL="postgresql://postgres@localhost/gsevpt"
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
flask db upgrade
|
flask db upgrade
|
||||||
flask run --host 0.0.0.0
|
gunicorn --bind 0.0.0.0:5000 project:app
|
||||||
```
|
```
|
||||||
|
|
||||||
## Scheduled/Cron jobs
|
## Scheduled/Cron jobs
|
||||||
|
|||||||
@ -56,3 +56,23 @@ pybabel extract -F babel.cfg -o messages.pot . && pybabel extract -F babel.cfg -
|
|||||||
```sh
|
```sh
|
||||||
pybabel compile -d project/translations
|
pybabel compile -d project/translations
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
### Build image
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build -t gsevpt:latest .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run container with existing postgres server
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker run -p 5000:5000 -e "FLASK_APP=main.py" -e "DATABASE_URL=postgresql://postgres@localhost/gsevpt" "gsevpt:latest"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compose (including Postgres server)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose build && docker-compose up
|
||||||
|
```
|
||||||
|
|||||||
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mdillon/postgis
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=gsevpt
|
||||||
|
- POSTGRES_USER=user
|
||||||
|
- POSTGRES_PASSWORD=pass
|
||||||
|
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
environment:
|
||||||
|
FLASK_APP: main.py
|
||||||
|
DATABASE_URL: postgresql://user:pass@db/gsevpt
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
environment:
|
||||||
|
FLASK_APP: main.py
|
||||||
|
DATABASE_URL: postgresql://user:pass@db/gsevpt
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
9
entrypoint.sh
Normal file
9
entrypoint.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
until flask db upgrade
|
||||||
|
do
|
||||||
|
echo "Waiting for postgres server to become available..."
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
gunicorn --bind 0.0.0.0:5000 project:app
|
||||||
Loading…
x
Reference in New Issue
Block a user