Skip to content

Commit

Permalink
update python version in runtime.txt and Dockerfile, fix sqlalchemy 1…
Browse files Browse the repository at this point in the history
….4.x bug
  • Loading branch information
eshaan7 committed Jul 29, 2021
1 parent 680de5f commit 1d5b98a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
FROM python:3.8.3-alpine3.12
FROM python:3.9-alpine

LABEL maintainer="[email protected]"

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

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

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

# Install RTB-CTF-Framework
WORKDIR /usr/src/app
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-for-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ services:
restart: unless-stopped
expose:
- "6379"

nginx:
image: library/nginx:1.16.1-alpine
image: library/nginx:1.21-alpine
container_name: rtb_nginx
restart: unless-stopped
hostname: nginx
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ services:
expose:
- "5432"
env_file:
- .env_postgres
- .env_postgres

redis:
image: redis:alpine3.12
container_name: rtb_redis
restart: unless-stopped
expose:
- "6379"

nginx:
image: library/nginx:1.16.1-alpine
image: library/nginx:1.21-alpine
container_name: rtb_nginx
restart: unless-stopped
hostname: nginx
Expand Down
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.8.7
python-3.9.6
5 changes: 4 additions & 1 deletion src/FlaskRTBCTF/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class Config:
DEBUG = False # Turn DEBUG OFF before deployment
SECRET_KEY = os.environ.get("SECRET_KEY", "you-will-never-guess")
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or "sqlite:///site.db"
_uri = os.environ.get("DATABASE_URL") or "sqlite:///site.db"
if _uri.startswith("postgres://"):
_uri = _uri.replace("postgres://", "postgresql://", 1)
SQLALCHEMY_DATABASE_URI = _uri
# For local use, one can simply use SQLlite with: 'sqlite:///site.db'
# For deployment on Heroku use: `os.environ.get('DATABASE_URL')`
# in all other cases: `os.environ.get('SQLALCHEMY_DATABASE_URI')`
Expand Down

0 comments on commit 1d5b98a

Please sign in to comment.