Skip to content

Commit cbb4fbe

Browse files
authored
Merge pull request #30 from edelgm6/flyio
fly io setup
2 parents 5ee8473 + 8d3abed commit cbb4fbe

File tree

6 files changed

+76
-17
lines changed

6 files changed

+76
-17
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fly.toml
2+
.git/
3+
*.sqlite3
4+
local_settings.py

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG PYTHON_VERSION=3.9-slim-bullseye
2+
3+
FROM python:${PYTHON_VERSION}
4+
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
# install psycopg2 dependencies.
9+
RUN apt-get update && apt-get install -y \
10+
libpq-dev \
11+
gcc \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
RUN mkdir -p /code
15+
16+
WORKDIR /code
17+
18+
COPY requirements.txt /tmp/requirements.txt
19+
RUN set -ex && \
20+
pip install --upgrade pip && \
21+
pip install -r /tmp/requirements.txt && \
22+
rm -rf /root/.cache/
23+
COPY . /code
24+
25+
ENV SECRET_KEY "DIMu8zimk0JhHbtkiChqTkfCYqjY0zFjRsDDug4ewLfinkcB00"
26+
RUN python manage.py collectstatic --noinput
27+
28+
EXPOSE 8000
29+
30+
CMD ["gunicorn", "--bind", ":8000", "--workers", "2", "holdem.wsgi"]

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

fly.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# fly.toml app configuration file generated for holdem on 2023-11-10T17:50:36-05:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = "holdem"
7+
primary_region = "atl"
8+
console_command = "/code/manage.py shell"
9+
10+
[build]
11+
12+
[deploy]
13+
release_command = "python manage.py migrate"
14+
15+
[env]
16+
PORT = "8000"
17+
18+
[http_service]
19+
internal_port = 8000
20+
force_https = true
21+
auto_stop_machines = true
22+
auto_start_machines = true
23+
min_machines_running = 0
24+
processes = ["app"]
25+
26+
[[statics]]
27+
guest_path = "/code/static"
28+
url_prefix = "/static/"

holdem/settings.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
55
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6-
6+
TEMPLATE_DIR = os.path.join(BASE_DIR,'play/templates')
77

88
# Quick-start development settings - unsuitable for production
99
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
@@ -13,9 +13,16 @@
1313

1414
# SECURITY WARNING: don't run with debug turned on in production!
1515
DEBUG = False
16+
SECURE_SSL_REDIRECT = True
1617

1718
ALLOWED_HOSTS = ['*']
19+
CSRF_TRUSTED_ORIGINS = ['https://*.fly.dev']
1820

21+
STATIC_ROOT = BASE_DIR + "staticfiles"
22+
STATIC_URL = '/play/static/'
23+
STATICFILES_DIRS = (
24+
os.path.join(BASE_DIR, 'play/static'),
25+
)
1926

2027
# Application definition
2128

@@ -46,7 +53,7 @@
4653
TEMPLATES = [
4754
{
4855
'BACKEND': 'django.template.backends.django.DjangoTemplates',
49-
'DIRS': [],
56+
'DIRS': [TEMPLATE_DIR],
5057
'APP_DIRS': True,
5158
'OPTIONS': {
5259
'context_processors': [
@@ -74,13 +81,11 @@
7481

7582
# Database
7683
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
77-
DATABASES = {
78-
"default": dj_database_url.config(
79-
conn_max_age=600,
80-
conn_health_checks=True,
81-
ssl_require=True,
82-
),
83-
}
84+
DATABASES = {'default': dj_database_url.config(conn_max_age=600)}
85+
DATABASES["default"].update({
86+
"ENGINE": "django.db.backends.postgresql_psycopg2",
87+
"OPTIONS": {"connect_timeout": 5}
88+
})
8489

8590
# Password validation
8691
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
@@ -113,12 +118,6 @@
113118

114119
USE_TZ = True
115120

116-
117-
# Static files (CSS, JavaScript, Images)
118-
119-
STATIC_ROOT = BASE_DIR + "/staticfiles"
120-
STATIC_URL = '/static/'
121-
122121
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
123122

124123
try:

runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)