Run code in container
This commit is contained in:
parent
2d51468eb1
commit
c46c2c5126
5 changed files with 42 additions and 6 deletions
8
leaderboard/.dockerignore
Normal file
8
leaderboard/.dockerignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.git
|
||||
.gitignore
|
||||
__pycache__
|
||||
README
|
||||
Makefile
|
||||
Dockerfile
|
||||
venv
|
||||
Containerfile
|
||||
19
leaderboard/Containerfile
Normal file
19
leaderboard/Containerfile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM python:3-alpine3.20 AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
FROM base AS reqs
|
||||
RUN pip install flask==3.1.0
|
||||
RUN pip install waitress==3.0.2
|
||||
|
||||
FROM reqs AS app
|
||||
RUN mkdir /app/templates
|
||||
COPY *.jinja2 /app/templates
|
||||
COPY app.py app.py
|
||||
|
||||
ENV AOC_TOKEN=
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME images
|
||||
|
||||
ENTRYPOINT waitress-serve app:app
|
||||
13
leaderboard/Makefile
Normal file
13
leaderboard/Makefile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
install:
|
||||
virtualenv venv
|
||||
. venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
waitress:
|
||||
waitress-serve app:app
|
||||
|
||||
flask:
|
||||
FLASK_APP=app flask run --debug
|
||||
|
||||
build:
|
||||
buildah build .
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
pip install flask
|
||||
mkdir templates
|
||||
mv main.jinja2 templates/
|
||||
AOC_TOKEN=<adventofcode.com session cookie> FLASK_APP=app flask run
|
||||
|
|
@ -32,9 +32,9 @@ def get_data(token, calendar, leaderboard, dummy_data=True):
|
|||
def hello_world():
|
||||
calendar = request.args.get("calendar", datetime.now().year)
|
||||
leaderboard = request.args.get("board")
|
||||
token = request.args.get("token")
|
||||
token = os.environ.get("AOC_TOKEN")
|
||||
if not token:
|
||||
return "Missing token get parameter. Use the session cookie on adventofcode.com"
|
||||
return "Missing AOC_TOKEN environment variable. Use the session cookie on adventofcode.com"
|
||||
if not leaderboard:
|
||||
return "Missing board get parameter."
|
||||
data = get_data(token, calendar, leaderboard, False)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue