Skip to content

Commit

Permalink
add docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
wuttinanhi committed Sep 19, 2022
1 parent 553ff14 commit c56aff6
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
3 changes: 2 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ ports:

vscode:
extensions:
- ms-azuretools.vscode-docker
- ms-vscode.makefile-tools
- VisualStudioExptTeam.vscodeintellicode
- ms-python.python
- rangav.vscode-thunder-client
- rangav.vscode-thunder-client
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim

EXPOSE 5000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt

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", "--bind", "0.0.0.0:5000", "main:app"]
14 changes: 14 additions & 0 deletions docker-compose.debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.4'

services:
carparkingreservationapi:
image: carparkingreservationapi
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=venv/lib64/python3.9/site-packages/flask/app.py
28 changes: 28 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3.4'

services:
mysql:
image: mysql
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: appdb
MYSQL_USER: appuser
MYSQL_PASSWORD: app-password
MYSQL_ROOT_PASSWORD: app-root-password
volumes:
- db_storage:/var/lib/mysql
ports:
- 3306:3306

phpmyadmin:
image: phpmyadmin
environment:
PMA_HOST: mysql
PMA_USER: appuser
PMA_PASSWORD: app-password
PMA_DATABASE: appdb
ports:
- 8080:80

volumes:
db_storage:
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.4'

services:
carparkingreservationapi:
image: carparkingreservationapi
build:
context: .
dockerfile: ./Dockerfile
ports:
- 5000:5000

0 comments on commit c56aff6

Please sign in to comment.