Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ludyn-leo committed Jan 8, 2021
0 parents commit 7ec9f53
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ignore files with below extensions
*.pyc
*.pyo
*.log
*.sqlite3

# ignore below files
.coverage
yarn.lock
package-lock.json
.env.secrets
.ash_history
.bash_history

# ignore below directories
__pycache__/
node_modules/
.cache/
.pytest_cache/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Description

Plain flask init project.

# Instructions

```bash
$ docker-compose up
```
8 changes: 8 additions & 0 deletions app/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask


app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello, World!'
1 change: 1 addition & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask
14 changes: 14 additions & 0 deletions app/scripts/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/ash

echo "Install requirements.txt"
pip install -r /app/requirements.txt --no-cache-dir

# is $@ empty
if [ -z "$@" ]
then
echo "Run App"
flask run --host=0.0.0.0 --port=$PORT
else
echo "Executeing \$@ command: $@"
exec $@
fi
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.8"
services:
app:
build:
context: ./app
dockerfile: ../docker/Dockerfile
image: flask/demo
container_name: flask-demo
hostname: flask-dev-demo
volumes:
- ./app:/app
# command: sleep 3600
30 changes: 30 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3.7.9-alpine

ARG PORT=8000
ENV PORT=$PORT
ARG FLASK_APP=/app/hello.py
ENV FLASK_APP=$FLASK_APP

ENV HOME=/app
ENV PYTHONUNBUFFERED=True
ENV PYTHONIOENCODING=UTF-8

WORKDIR /app
COPY . /app

# Fixed permissions, create exec:exec and dev:dev
RUN sed -i '/999/d;' /etc/group
RUN addgroup -S -g 999 exec && adduser -u 999 -s /sbin/nologin -SDHG exec exec
RUN adduser -DH dev && adduser exec dev
RUN chown -R exec:dev \
/app \
/usr/local/bin/ \
/usr/local/lib/python3.7/
RUN chmod -R a-w /etc

VOLUME /app
EXPOSE ${PORT}

USER exec:dev

ENTRYPOINT ["/app/scripts/startup.sh"]

0 comments on commit 7ec9f53

Please sign in to comment.