Skip to content

Commit

Permalink
Merge pull request #51 from openfido/fix/change-req
Browse files Browse the repository at this point in the history
Fix/change req
  • Loading branch information
Thistleman committed Feb 23, 2023
2 parents 030abd3 + 7cfa34c commit c11638c
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 50 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!*.py
!app
!migrations
!*.txt
9 changes: 6 additions & 3 deletions .github/workflows/docker-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ jobs:
with:
python-version: 3.8

- name: install pipenv
- name: install/upgrade pip
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Install Dependencies
run: python -m pip install -r requirements.txt

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -61,7 +64,7 @@ jobs:
eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa
export DOCKER_BUILDKIT=1
docker build --ssh default=${SSH_AUTH_SOCK} -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/docker-deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
build:
runs-on: ubuntu-latest
environment: Build
env:
PIPENV_VENV_IN_PROJECT: true
steps:
- name: Checkout Repository
uses: actions/checkout@v3
Expand All @@ -26,30 +24,18 @@ jobs:
with:
python-version: 3.8

- name: install pipenv
- name: install/upgrade pip
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Cache pip environment
uses: actions/cache@v3
env:
cache-name: cache-pipenv
with:
path: .venv
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-
${{ runner.os }}-python-
${{ runner.os }}-
- name: Install Dependencies
run: pipenv install --dev --deploy
run: python -m pip install -r requirements.txt

- name: Build
run: |
mkdir test-results
pipenv run invoke test --junit --enforce-percent 97
python3 -m invoke test --junit --enforce-percent 97
- name: Store test results as artifacts
uses: actions/upload-artifact@v2
Expand All @@ -58,10 +44,10 @@ jobs:
path: test-results

- name: Style
run: pipenv run invoke style
run: python3 -m invoke style

- name: Lint
run: pipenv run invoke lint --fail-under=9
run: python3 -m invoke lint --fail-under=9

deploy-staging:
needs: build
Expand Down Expand Up @@ -92,10 +78,9 @@ jobs:
with:
python-version: 3.8

- name: install pipenv
- name: install/upgrade pip
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -120,7 +105,7 @@ jobs:
eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa
export DOCKER_BUILDKIT=1
docker build --ssh default=${SSH_AUTH_SOCK} -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Expand Down
24 changes: 5 additions & 19 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
test-build:
runs-on: ubuntu-latest
environment: Build
env:
PIPENV_VENV_IN_PROJECT: true
steps:
- name: Checkout Repository
uses: actions/checkout@v3
Expand All @@ -26,30 +24,18 @@ jobs:
with:
python-version: 3.8

- name: install pipenv
- name: install/upgrade pip
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Cache pip environment
uses: actions/cache@v3
env:
cache-name: cache-pipenv
with:
path: .venv
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-
${{ runner.os }}-python-
${{ runner.os }}-
- name: Install Dependencies
run: pipenv install --dev --deploy
run: python -m pip install -r requirements.txt

- name: Build
run: |
mkdir test-results
pipenv run invoke test --junit --enforce-percent 97
python -m invoke test --junit --enforce-percent 97
- name: Store test results as artifacts
uses: actions/upload-artifact@v2
Expand All @@ -58,7 +44,7 @@ jobs:
path: test-results

- name: Style
run: pipenv run invoke style
run: python -m invoke style

- name: Lint
run: pipenv run invoke lint --fail-under=9
run: python -m invoke lint --fail-under=9
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1.0.0-experimental
FROM python:3.8-slim as base

SHELL ["/bin/bash", "-c"]

ENV PORT 5000
ENV FLASK_APP run.py
ENV FLASK_ENV production
Expand All @@ -18,17 +20,16 @@ RUN chmod 600 ~/.ssh/id_rsa
RUN touch ~/.ssh/known_hosts
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts

ADD Pipfile .
ADD Pipfile.lock .
RUN pip install pipenv
RUN --mount=type=ssh PIPENV_VENV_IN_PROJECT=1 pipenv install --dev --deploy
ADD requirements.txt .
RUN python3 -m venv /.venv
RUN source /.venv/bin/activate
RUN /.venv/bin/python3 -m pip install -r requirements.txt

FROM base as runtime

RUN apt-get update -qq && \
apt-get install -y pipenv \
# for db connectivity
postgresql-client \
apt-get install -y postgresql-client \
# for healthcheck
curl \
&& \
Expand All @@ -38,6 +39,7 @@ RUN mkdir /opt/app
WORKDIR /opt/app

COPY --from=python-deps /.venv /.venv
RUN source /.venv/bin/activate
ENV PATH="/.venv/bin:$PATH"

COPY . .
Expand Down
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2019, The Board of Trustees of the Leland Stanford Junior University.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 changes: 63 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
alembic==1.4.3
attrs==20.2.0
boto3==1.16.9
botocore==1.19.9
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
coverage==5.3
flask==1.1.2
flask-cors==3.0.9
flask-migrate==2.5.3
flask-sqlalchemy==2.4.4
idna==2.10
iniconfig==1.1.1
itsdangerous==1.1.0
jinja2==2.11.2
jmespath==0.10.0
mako==1.1.3
markupsafe==1.1.1
marshmallow==3.9.0
marshmallow-enum==1.5.1
packaging==20.4
git+ssh://git@github.com/slacgismo/openfido-utils.git
pluggy==0.13.1
psycopg2-binary==2.8.6
py==1.9.0
pyjwt==1.7.1
pyparsing==2.4.7
pytest==6.1.2
pytest-cov==2.10.1
python-dateutil==2.8.1
python-dotenv==0.15.0
python-editor==1.0.4
requests==2.24.0
s3transfer==0.3.3
simplejson==3.17.2
six==1.15.0
sqlalchemy==1.3.20
toml==0.10.2
urllib3==1.25.11
werkzeug==1.0.1
appdirs==1.4.4
astroid==2.4.2
black==20.8b1
certifi==2020.6.20
flasgger==0.9.5
invoke==1.4.1
isort==5.6.4
jsonschema==3.2.0
lazy-object-proxy==1.4.3
mccabe==0.6.1
mistune==0.8.4
mypy-extensions==0.4.3
pathspec==0.8.0
pylint==2.6.0
pylint-flask-sqlalchemy==0.2.0
pyrsistent==0.17.3
pyyaml==5.3.1
regex==2020.10.28
responses==0.12.0
typed-ast==1.4.1
typing-extensions==3.7.4.3
wrapt==1.12.1

0 comments on commit c11638c

Please sign in to comment.