-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (23 loc) · 1.53 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
FROM python:3.11-slim AS api
COPY requirements.txt package.json /srv/
COPY flask_api /srv/flask_api/
WORKDIR /srv/
RUN apt-get update && apt-get install -y libexpat1
RUN pip install -r requirements.txt --src /usr/local/src
RUN touch .env && pip install pyuwsgi --src /usr/local/src
CMD cd flask_api && flask db upgrade && flask create_superuser && cd .. && uwsgi --http-socket 0.0.0.0:8000 --wsgi-file flask_api/app.py --callable app --processes 4 --threads 2
# Run tests
FROM api AS test
ENV USERNAME=testusername
ENV PASSWORD=testpassword
ENV SECRET=testsecret
ENV DATABASE_FILE=testdb.sqlite3
ARG sqlalchemy_database_uri
ENV SQLALCHEMY_DATABASE_URI=$sqlalchemy_database_uri
#sqlite3 testdb.sqlite3 < flask_api/schema.sql
#echo "INSERT INTO users (username, password) VALUES ('testusername','9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05')" | sqlite3 testdb.sqlite3
#gzip -c /tmp/db.sqlite3 | base64
RUN echo 'H4sICPXycWUAA2RiLnNxbGl0ZTMA7dq/a8JAFAfwO+1PwdotU+GWgqKUmBBitqYlFNsYNY20TuWSXECoWk2kQyf/oP57nXuJlKJLVynfD/eOe3l5uflBHofuJBMsmS+nPGM6OSeUkmvGCCElGWXyi8o42Mn/UiJXT/fV/FC7ILW53AAAAAAAAAD2zaB0pDSbdJzx8FWki1c5Kb+kYrESs2g3Ld/6jh04LLBvXIftFOszPhUtmTXWZ/RYURS6/ii+uUrFMi220lZ/8YjVK0yaxKzrBc6d47OB3+3Z/pg9OGNmj4J+15NdPccLWsWbeVd+Ewuc54B5fRkj193U3niavs+X8Xat0shnc1r7JHIBAAAAAAAAwD4Y0kNyua5mIs1+Zn0rMXVDqHFi8XYcR6aqhYnK29wMO7qq64mstw2dq2qkWbHoaJGIeRxZlmFqHStUjc38/0XkAgAAAAAAAIB/5YSWldPiJ4NvkJuJtAAwAAA=' | base64 -d | zcat > $DATABASE_FILE
# Put in test data
WORKDIR /srv/flask_api
RUN flask db upgrade && flask create_superuser && pytest