fix: api/Dockerfile to reduce vulnerabilities #203
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
name: FastAPI (API) CI | |
on: | |
push: | |
paths: | |
- 'api/**' | |
- '.github/workflows/api-ci.yml' | |
jobs: | |
pytest: | |
strategy: | |
matrix: | |
python-version: ["3.10.4"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Switch to Current Branch | |
run: git checkout ${{ env.BRANCH }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
cd api | |
python -m pip install --upgrade pip | |
python -m pip install pipenv | |
pipenv install --dev | |
- name: Create .env file | |
run: echo "${{ secrets.BACKEND_TEST_ENVS }}" > ./api/src/.env | |
- name: Set up psql container | |
run: | | |
docker run -d \ | |
--network host \ | |
--name sr-test-database \ | |
-e POSTGRES_PASSWORD=postgres \ | |
-e PGDATA=/var/lib/postgresql/data/pgdata \ | |
postgres | |
- name: Wait for db to boot | |
run: | | |
cd database && chmod +x wait-for-db.sh && ./wait-for-db.sh | |
- name: Create Snapping Rails database | |
run: | | |
docker exec -i sr-test-database createdb -U postgres snapping-rails | |
- name: Load Snapping Rails database with test data | |
run: | | |
cd database && cat db.sql | docker exec -i sr-test-database psql -U postgres -d snapping-rails | |
- name: Run pytests | |
run: | | |
cd api && pipenv run python -m pytest --import-mode=append tests/ | |