added auto-generated stuff from vs code, not sure if it works yet but it looks good.

This commit is contained in:
Solomon Laing 2021-06-03 08:59:19 +09:30
parent f30215ffe9
commit d69ae01232
8 changed files with 150 additions and 32 deletions

26
.dockerignore Normal file
View File

@ -0,0 +1,26 @@
**/__pycache__
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md

19
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Docker: Python - Flask",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "flask"
}
}
]
}

40
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,40 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "python",
"dockerBuild": {
"tag": "simpleblogapi:latest",
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build"
],
"dockerRun": {
"env": {
"FLASK_APP": "wsgi.py"
}
},
"python": {
"args": [
"run",
"--no-debugger",
"--no-reload",
"--host",
"0.0.0.0",
"--port",
"5000"
],
"module": "flask"
}
}
]
}

View File

@ -1,17 +1,26 @@
FROM python:3.8 # For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster
RUN pip3 install pipenv gunicorn
EXPOSE 5000
ENV PROJECT_DIR /usr/src/simpleblogapi
# Keeps Python from generating .pyc files in the container
WORKDIR ${PROJECT_DIR} ENV PYTHONDONTWRITEBYTECODE=1
COPY Pipfile . # Turns off buffering for easier container logging
COPY Pipfile.lock . ENV PYTHONUNBUFFERED=1
COPY . .
# Install pip requirements
RUN pipenv install --deploy --ignore-pipfile COPY Pipfile .
COPY Pipfile.lock .
EXPOSE 5400 RUN pipenv install --deploy --ignore-pipfile
CMD ["gunicorn", "-c", "gunicorn_config.py", "wsgi:api"] WORKDIR /app
COPY . /app
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "-c", "gunicorn_config.py", "wsgi:api"]

14
docker-compose.debug.yml Normal file
View File

@ -0,0 +1,14 @@
version: '3.4'
services:
simpleblogapi:
image: simpleblogapi
build:
context: .
dockerfile: ./Dockerfile
command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5000"]
ports:
- 5000:5000
- 5678:5678
environment:
- FLASK_APP=wsgi.py

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: '3.4'
services:
simpleblogapi:
image: simpleblogapi
build:
context: .
dockerfile: ./Dockerfile
ports:
- 5000:5000

View File

@ -1,4 +1,4 @@
# to run: gunicorn -c gunicorn_config.py wsgi:api # to run: gunicorn -c gunicorn_config.py wsgi:api
bind = "0.0.0.0:5400" bind = "0.0.0.0:5000"
workers = 2 workers = 2

View File

@ -1,14 +1,14 @@
aniso8601==9.0.1 # To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
beautifulsoup4==4.9.3 flask==1.1.2
click==8.0.1 gunicorn==20.0.4
Flask==2.0.1 aniso8601==9.0.1
Flask-RESTful==0.3.9 beautifulsoup4==4.9.3
gunicorn==20.1.0 click==8.0.1
itsdangerous==2.0.1 Flask-RESTful==0.3.9
Jinja2==3.0.1 itsdangerous==2.0.1
Markdown==3.3.4 Jinja2==3.0.1
MarkupSafe==2.0.1 Markdown==3.3.4
pytz==2021.1 MarkupSafe==2.0.1
six==1.16.0 pytz==2021.1
soupsieve==2.2.1 six==1.16.0
Werkzeug==2.0.1 soupsieve==2.2.1