initial commit, adding flask structure, README, routes
- routes defined in routes.py uses the <path:..> function to catch every non-empty url comming along - request.full_path is used to get the entire url, as <path:> would remove eg GET '?' from the url, which we don't want for the link forwarding. - request.full_path[1:] removes the '/' from the url
This commit is contained in:
7
docker/README.md
Normal file
7
docker/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
## Goal
|
||||
|
||||
run short-server in a docker-compose environment
|
||||
|
||||
## Usage
|
||||
|
||||
1. `docker-compose up -d` starts the containers in background
|
28
docker/docker-compose.yml
Normal file
28
docker/docker-compose.yml
Normal file
@ -0,0 +1,28 @@
|
||||
version: '3'
|
||||
services:
|
||||
short-server:
|
||||
build:
|
||||
context: ./short-server
|
||||
image: daria/short-server:latest
|
||||
container_name: short-server
|
||||
environment:
|
||||
- FLASK_APP=/home/short-server/server.py
|
||||
- FLASK_ENV=development
|
||||
volumes:
|
||||
- ../:/home/short-server
|
||||
ports:
|
||||
- "0.0.0.0:8086:8086"
|
||||
networks:
|
||||
net:
|
||||
ipv4_address: '172.25.0.12'
|
||||
|
||||
volumes:
|
||||
database:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
net:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.25.0.0/24
|
8
docker/short-server/Dockerfile
Normal file
8
docker/short-server/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM python:3.8-slim-buster
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
RUN apt-get install gcc libmariadbclient-dev -y
|
||||
RUN pip3 install google-oauth google-api-python-client
|
||||
RUN pip3 install flask Flask-SQLAlchemy flask_migrate flask_wtf python-dotenv mysqlclient
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
EXPOSE 3001
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
12
docker/short-server/docker-entrypoint.sh
Executable file
12
docker/short-server/docker-entrypoint.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
sleep 5
|
||||
|
||||
if [[ "$1" = "shell" ]]; then
|
||||
exec /bin/bash
|
||||
fi
|
||||
|
||||
cd /home/short-server
|
||||
python3 server.py
|
||||
|
Reference in New Issue
Block a user