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

Fly #213

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

Fly #213

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# flyctl launch added from .gitignore
# Byte-compiled / optimized / DLL files
**/__pycache__
**/*.py[cod]
**/*$py.class

# C extensions
**/*.so

# Distribution / packaging
**/.Python
**/build
**/develop-eggs
**/dist
**/downloads
**/eggs
**/.eggs
**/lib
**/lib64
**/parts
**/sdist
**/var
**/wheels
**/pip-wheel-metadata
**/share/python-wheels
**/*.egg-info
**/.installed.cfg
**/*.egg
**/MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
**/*.manifest
**/*.spec

# Installer logs
**/pip-log.txt
**/pip-delete-this-directory.txt

# Unit test / coverage reports
**/htmlcov
**/.tox
**/.nox
**/.coverage
**/.coverage.*
**/.cache
**/nosetests.xml
**/coverage.xml
**/*.cover
**/*.py,cover
**/.hypothesis
**/.pytest_cache

# Translations
**/*.pot

# Django stuff:
**/*.log
**/local_settings.py
**/db.sqlite3
**/db.sqlite3-journal

# Flask stuff:
**/instance
**/.webassets-cache

# Scrapy stuff:
**/.scrapy

# Sphinx documentation
**/docs/_build

# PyBuilder
**/target

# Jupyter Notebook
**/.ipynb_checkpoints

# IPython
**/profile_default
**/ipython_config.py

# pyenv
**/.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
**/__pypackages__

# Celery stuff
**/celerybeat-schedule
**/celerybeat.pid

# SageMath parsed files
**/*.sage.py

# Environments
**/.venv
**/env
**/venv
**/ENV
**/env.bak
**/venv.bak

# Spyder project settings
**/.spyderproject
**/.spyproject

# Rope project settings
**/.ropeproject

# mkdocs documentation
site

# mypy
**/.mypy_cache
**/.dmypy.json
**/dmypy.json

# Pyre type checker
**/.pyre

# Pycharm
**/.idea

# website files
**/website/*.sqlite3
**/**/media/*
**/database
**/*.sqlite

# secrets
**/config/secrets.env

**/.vscode

**/**/main.css

# flyctl launch added from .idea/.gitignore
# Default ignored files
.idea/shelf
.idea/workspace.xml
# Datasource local storage ignored files
.idea/dataSources
.idea/dataSources.local.xml
# Editor-based HTTP Client requests
.idea/httpRequests
1 change: 0 additions & 1 deletion .env

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,6 @@ config/secrets.env

**/main.css

.direnv/
.direnv/
.envrc
.env
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.1.3 \
POETRY_VERSION=1.4.0 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1
POETRY_NO_INTERACTION=1 \
POETRY_HOME="/opt/poetry"
# Use production settings
ENV DJANGO_SETTINGS_MODULE website.settings.production
# Add poetry to PATH
ENV PATH="/root/.poetry/bin:$PATH"
ENV PATH="$POETRY_HOME/bin:$PATH"

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
Expand All @@ -25,7 +26,7 @@ RUN apt-get update \
postgresql-client

# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
RUN curl -sSL https://install.python-poetry.org | python3 -

WORKDIR /bf2-www

Expand All @@ -41,4 +42,10 @@ COPY config/entrypoint.sh ./
# Copy the rest of the code.
COPY website ./

# Compile scss to css
#RUN ./manage.py compilescss
#
## Collect all static files for serving
#RUN ./manage.py collectstatic --no-input

ENTRYPOINT ["./entrypoint.sh"]
9 changes: 1 addition & 8 deletions config/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

set -e

echo "Waiting for postgres at host ${DATABASE_HOST}"
until pg_isready --host="${DATABASE_HOST}" --port="${DATABASE_PORT}" --username="${POSTGRES_USER}" --quiet; do
sleep 1;
done

echo "Postgres database is up"

. .venv/bin/activate

echo "Performing migrations"
Expand All @@ -23,4 +16,4 @@ echo "Collecting static files"
chown --recursive www-data:www-data /bf2-www/

echo "Starting server"
gunicorn --bind :8000 website.wsgi:application
gunicorn --bind :8080 website.wsgi:application
40 changes: 40 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
description = "BF2 djangocms website";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
nativeBuildInputs = [ pkgs.bashInteractive ];
buildInputs = with pkgs; [
python311
gtranslator
poedit
poetry
flyctl
openssl
httpie
];
};
});
}
43 changes: 43 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# fly.toml file generated for bf2-website on 2023-03-24T13:30:48+01:00

app = "bf2-website"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[metrics]
port = 9091 # default for most prometheus clients
path = "/metrics" # default for most prometheus clients

[env]
DOMAIN="bfrisbee2s.nl"
EMAIL_HOST_USER="[email protected]"

[experimental]
auto_rollback = true

[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "15s"
interval = "15s"
restart_limit = 40
timeout = "2s"
Loading