Skip to content
This repository was archived by the owner on Jul 20, 2019. It is now read-only.

Commit b420a7d

Browse files
authored
Merge pull request #21 from jehrhardt/server-prototype
Server prototype
2 parents eda2123 + fcd1ab3 commit b420a7d

File tree

183 files changed

+10956
-3655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+10956
-3655
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.venv
2+
.vscode
3+
ui/node_modules
4+
ui/build
5+
server/static
6+
__pycache__

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
# VisualStudio Code specific
12
.vscode
3+
4+
# macOS specific
25
.DS_Store
6+
7+
# Python specific
8+
.venv
9+
__pycache__/
10+
instance
11+
12+
# Node.js specific
13+
node_modules
14+
.eslintcache
15+
build
16+
server/static

.travis.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
language: node_js
2-
node_js:
3-
- "10"
1+
services:
2+
- docker
43

5-
install:
6-
- npm --prefix=web ci
7-
script: npm --prefix=web run-script lint
8-
9-
cache:
10-
directories:
11-
- "$HOME/.npm"
4+
script: DOCKER_BUILDKIT=1 docker build -t werkstatt .

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Python base image for build and production
2+
FROM alpine:3.8 AS python
3+
4+
RUN apk add --no-cache python3 \
5+
libpq
6+
7+
# Build server
8+
FROM python AS build-server
9+
10+
WORKDIR /werkstatt
11+
RUN apk add --no-cache --virtual .build-deps \
12+
py3-pip \
13+
gcc \
14+
python3-dev \
15+
musl-dev \
16+
postgresql-dev
17+
RUN pip3 install --upgrade pip
18+
ADD requirements-dev.txt /werkstatt/
19+
RUN pip3 install --no-cache-dir --requirement requirements-dev.txt
20+
ADD requirements.txt /werkstatt/
21+
RUN pip3 install --no-cache-dir --requirement requirements.txt --target requirements
22+
23+
ADD server /werkstatt/server
24+
25+
# Build UI
26+
FROM node:10-alpine AS build-ui
27+
28+
WORKDIR /werkstatt/ui
29+
ADD ui/package.json ui/package-lock.json /werkstatt/ui/
30+
RUN npm install
31+
ADD ui /werkstatt/ui
32+
RUN npm run-script build
33+
34+
# Build release image
35+
FROM python
36+
37+
WORKDIR /usr/local/lib/werkstatt
38+
EXPOSE 4000
39+
ENV PYTHONPATH /usr/local/lib/werkstatt/requirements
40+
CMD [ "requirements/bin/gunicorn", "-w", "4", "-b", "0.0.0.0:4000", "server:create_app()" ]
41+
42+
COPY --from=build-server /werkstatt/requirements /usr/local/lib/werkstatt/requirements
43+
COPY --from=build-server /werkstatt/server /usr/local/lib/werkstatt/server
44+
COPY --from=build-ui /werkstatt/ui/build /usr/local/lib/werkstatt/server/static

api/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

api/requirements-dev.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

api/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

api/werkstatt.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '3.4'
2+
services:
3+
server:
4+
build:
5+
context: .
6+
target: build-server
7+
depends_on:
8+
- db
9+
volumes:
10+
- ./server:/werkstatt/server
11+
- ./migrations:/werkstatt/migrations
12+
ports:
13+
- '5000:5000'
14+
environment:
15+
FLASK_APP: server
16+
FLASK_ENV: development
17+
PYTHONPATH: /werkstatt/requirements
18+
networks:
19+
- default
20+
command: requirements/bin/flask run --host=0.0.0.0
21+
22+
db:
23+
image: 'postgres:11-alpine'
24+
ports:
25+
- '5432:5432'
26+
environment:
27+
POSTGRES_USER: werkstatt
28+
POSTGRES_PASSWORD: werkstatt
29+
POSTGRES_DB: werkstatt
30+
networks:
31+
- default

migrations/alembic.ini

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# template used to generate migration files
5+
# file_template = %%(rev)s_%%(slug)s
6+
7+
# set to 'true' to run the environment during
8+
# the 'revision' command, regardless of autogenerate
9+
# revision_environment = false
10+
11+
12+
# Logging configuration
13+
[loggers]
14+
keys = root,sqlalchemy,alembic
15+
16+
[handlers]
17+
keys = console
18+
19+
[formatters]
20+
keys = generic
21+
22+
[logger_root]
23+
level = WARN
24+
handlers = console
25+
qualname =
26+
27+
[logger_sqlalchemy]
28+
level = WARN
29+
handlers =
30+
qualname = sqlalchemy.engine
31+
32+
[logger_alembic]
33+
level = INFO
34+
handlers =
35+
qualname = alembic
36+
37+
[handler_console]
38+
class = StreamHandler
39+
args = (sys.stderr,)
40+
level = NOTSET
41+
formatter = generic
42+
43+
[formatter_generic]
44+
format = %(levelname)-5.5s [%(name)s] %(message)s
45+
datefmt = %H:%M:%S

0 commit comments

Comments
 (0)