Skip to content

Commit 1d5b98a

Browse files
committed
update python version in runtime.txt and Dockerfile, fix sqlalchemy 1.4.x bug
1 parent 680de5f commit 1d5b98a

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
FROM python:3.8.3-alpine3.12
1+
FROM python:3.9-alpine
22

33
LABEL maintainer="eshaan7bansal@gmail.com"
44

55
# Env
6-
RUN export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@postgres:${DB_PORT}/${DB_NAME}" \
6+
RUN export DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@postgres:${DB_PORT}/${DB_NAME}" \
77
&& export REDIS_URL="redis://redis:6379/0"
88

99
# update and install packages
1010
RUN apk update --no-cache \
1111
&& apk add --no-cache postgresql-dev build-base g++ libffi-dev
1212

13-
# Add a new low-privileged user
14-
RUN adduser --shell /sbin/login www-data -DH
13+
# ensure www-data user exists (low-privileged user)
14+
RUN set -x ; \
15+
addgroup -g 82 -S www-data ; \
16+
adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
1517

1618
# Install RTB-CTF-Framework
1719
WORKDIR /usr/src/app

docker-compose-for-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ services:
2828
restart: unless-stopped
2929
expose:
3030
- "6379"
31-
31+
3232
nginx:
33-
image: library/nginx:1.16.1-alpine
33+
image: library/nginx:1.21-alpine
3434
container_name: rtb_nginx
3535
restart: unless-stopped
3636
hostname: nginx

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ services:
1919
expose:
2020
- "5432"
2121
env_file:
22-
- .env_postgres
22+
- .env_postgres
2323

2424
redis:
2525
image: redis:alpine3.12
2626
container_name: rtb_redis
2727
restart: unless-stopped
2828
expose:
2929
- "6379"
30-
30+
3131
nginx:
32-
image: library/nginx:1.16.1-alpine
32+
image: library/nginx:1.21-alpine
3333
container_name: rtb_nginx
3434
restart: unless-stopped
3535
hostname: nginx

runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.8.7
1+
python-3.9.6

src/FlaskRTBCTF/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
class Config:
77
DEBUG = False # Turn DEBUG OFF before deployment
88
SECRET_KEY = os.environ.get("SECRET_KEY", "you-will-never-guess")
9-
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or "sqlite:///site.db"
9+
_uri = os.environ.get("DATABASE_URL") or "sqlite:///site.db"
10+
if _uri.startswith("postgres://"):
11+
_uri = _uri.replace("postgres://", "postgresql://", 1)
12+
SQLALCHEMY_DATABASE_URI = _uri
1013
# For local use, one can simply use SQLlite with: 'sqlite:///site.db'
1114
# For deployment on Heroku use: `os.environ.get('DATABASE_URL')`
1215
# in all other cases: `os.environ.get('SQLALCHEMY_DATABASE_URI')`

0 commit comments

Comments
 (0)