Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added github workflow. Dockerized and poetrized app. #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is a basic workflow to help you get started with Actions

name: Unittests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

# This workflow contains a single job called "build"
build:
environment: Master
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- run: touch .env
- run: docker-compose pull

# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- uses: satackey/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- run: docker-compose build

# Runs a single command using the runners shell
- name: Run Unit Tests
run: docker-compose run web poetry run python -m unittest
- name: Build and publish to pypi
if: github.ref == 'refs/heads/master'
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM capless/capless-docker:jupyter
COPY . /code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this COPY before the Poetry install will cause Docker's layer caching to assume it needs to reinstall poetry whenever the source code changes. Moving this after installing Poetry will allow that layer to be cached and save time on subsequent builds.

RUN python -m pip install --upgrade poetry

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is not Poetry's recommended method of installing Poetry: https://python-poetry.org/docs/#installation

RUN poetry run pip install --upgrade pip

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modern versions of Poetry use an internal installer and not pip anymore, so this may not be necessary.

RUN poetry install
18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.7'

services:
web:
restart: always
build:
dockerfile: Dockerfile
context: .
expose:
- "8011"
Comment on lines +9 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expose exposes this port to other services in this Docker network (eg, defined in this docker-compose.yml file). Since you have none, and so no other containers that will want to talk to this one, this isn't necessary.

ports:
- 8011:8888
volumes:
- ./sammy/:/code/sammy
Comment on lines +13 to +14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have been copy-pasta'ed from whatever example you used, but wouldn't work based on directories in this repo. Looking at the Dockerfile I"m imagining what you want is

Suggested change
volumes:
- ./sammy/:/code/sammy
volumes:
- .:/code/

env_file: .env
working_dir: /code/
command: /root/.cache/pypoetry/virtualenvs/envs-MATOk_fk-py3.9/bin/jupyter notebook --port=8888 --ip=0.0.0.0 --allow-root

Loading