-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Docker image
- Loading branch information
Showing
11 changed files
with
251 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
*,cover | ||
*.log | ||
*.pyc | ||
*.pyd | ||
*.pyo | ||
.DS_Store | ||
.Python | ||
.cache | ||
.coverage | ||
.coverage.* | ||
.dockerignore | ||
.editorconfig | ||
.git | ||
.github/ | ||
.gitignore | ||
.pytest_cache | ||
.tox | ||
.vscode | ||
/setup.cfg | ||
app.yaml | ||
cron.yaml | ||
Dockerfile | ||
LICENSE | ||
README.md | ||
__pycache__ | ||
cloudbuild.yaml | ||
coverage.xml | ||
env | ||
nosetests.xml | ||
pip-delete-this-directory.txt | ||
pip-log.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.py] | ||
indent_size = 4 | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
pip install coverage flake8 | ||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
|
@@ -40,7 +40,6 @@ jobs: | |
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Run tests with Coverage | ||
run: | | ||
export SSL_CERT_FILE=./ca.pem | ||
coverage run --source=./ --omit=test.py test.py | ||
coverage report -m | ||
coverage xml | ||
|
@@ -49,3 +48,85 @@ jobs: | |
if: matrix.python-version == '3.9' | ||
with: | ||
flags: unittests | ||
|
||
docker-test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-build-x-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-build-x | ||
- name: Build | ||
uses: docker/[email protected] | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
push: false | ||
load: false | ||
target: test | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
docker-prod: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
arch: [linux/amd64, linux/arm64] | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-build-x-${{ matrix.arch }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-build-x-${{ matrix.arch }}- | ||
- name: Build | ||
uses: docker/[email protected] | ||
with: | ||
platforms: ${{ matrix.arch }} | ||
push: false | ||
load: true | ||
tags: oittaa/ibkr-report-parser:latest | ||
target: prod | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
- name: Docker container up | ||
run: docker run -d --rm -p 8080:8080 --name ibkr-report-parser oittaa/ibkr-report-parser | ||
- name: Wait 10 seconds | ||
run: sleep 10 | ||
- name: Check running containers | ||
run: docker ps -a | ||
- name: Check the container reachability | ||
run: curl -s --retry 10 --retry-connrefused http://localhost:8080/ | ||
- name: Check Docker logs | ||
run: docker logs ibkr-report-parser | ||
- name: Docker container down | ||
run: docker stop ibkr-report-parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
pip install coverage flake8 | ||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
|
@@ -37,7 +37,88 @@ jobs: | |
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Run tests with Coverage | ||
run: | | ||
export SSL_CERT_FILE=./ca.pem | ||
coverage run --source=./ --omit=test.py test.py | ||
coverage report -m | ||
coverage xml | ||
docker-test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-build-x-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-build-x | ||
- name: Build | ||
uses: docker/[email protected] | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
push: false | ||
load: false | ||
target: test | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
docker-prod: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
arch: [linux/amd64, linux/arm64] | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-build-x-${{ matrix.arch }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-build-x-${{ matrix.arch }}- | ||
- name: Build | ||
uses: docker/[email protected] | ||
with: | ||
platforms: ${{ matrix.arch }} | ||
push: false | ||
load: true | ||
tags: oittaa/ibkr-report-parser:latest | ||
target: prod | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
- name: Docker container up | ||
run: docker run -d --rm -p 8080:8080 --name ibkr-report-parser oittaa/ibkr-report-parser | ||
- name: Wait 10 seconds | ||
run: sleep 10 | ||
- name: Check running containers | ||
run: docker ps -a | ||
- name: Check the container reachability | ||
run: curl -s --retry 10 --retry-connrefused http://localhost:8080/ | ||
- name: Check Docker logs | ||
run: docker logs ibkr-report-parser | ||
- name: Docker container down | ||
run: docker stop ibkr-report-parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM python:3.10.0-slim AS base | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
# Allow statements and log messages to immediately appear in the Knative logs | ||
ENV PYTHONUNBUFFERED True | ||
ENV APP_HOME /app | ||
ENV GUNICORN_WORKERS 1 | ||
ENV GUNICORN_THREADS 8 | ||
ENV PORT 8080 | ||
|
||
WORKDIR $APP_HOME | ||
COPY main.py requirements.txt ./ | ||
COPY static/ ./static/ | ||
COPY templates/ ./templates/ | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
FROM base AS test | ||
COPY test-data/ ./test-data/ | ||
COPY test.py requirements-dev.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements-dev.txt && \ | ||
coverage run --source=./ --omit=test.py test.py && \ | ||
coverage report -m | ||
|
||
FROM base AS prod | ||
ENTRYPOINT [] | ||
CMD exec gunicorn --bind :$PORT --workers $GUNICORN_WORKERS --threads $GUNICORN_THREADS --timeout 0 main:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage==6.0.2 | ||
flake8==4.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
flask==2.0.2 | ||
google-cloud-storage==1.42.3 | ||
gunicorn==20.1.0 |