Skip to content

Commit e44b719

Browse files
author
Måns Magnusson
authored
Docker production image (#80)
* Adds workflow for pushing docker image to docker-hub
1 parent d16591a commit e44b719

File tree

6 files changed

+158
-0
lines changed

6 files changed

+158
-0
lines changed

.dockerignore

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Mac OSX hidden files
2+
.DS_Store
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
8+
# C extensions
9+
*.so
10+
11+
# Packages
12+
*.egg
13+
*.egg-info
14+
dist
15+
build
16+
eggs
17+
parts
18+
bin
19+
var
20+
sdist
21+
develop-eggs
22+
.installed.cfg
23+
lib
24+
lib64
25+
26+
# Installer logs
27+
pip-log.txt
28+
29+
# Unit test / coverage reports
30+
.coverage
31+
.tox
32+
nosetests.xml
33+
htmlcov
34+
.cache/
35+
.coverage*
36+
37+
# Translations
38+
*.mo
39+
40+
# Mr Developer
41+
.mr.developer.cfg
42+
.project
43+
.pydevproject
44+
.env
45+
TRASH*
46+
*.tar.gz
47+
.vagrant
48+
_DEVELOP/
49+
.vscode/
50+
51+
# Editors
52+
*.sublime-workspace
53+
.tm_properties
54+
.idea
55+
56+
# project files should be version controlled, unless a significant
57+
# proportion of contributors will probably not be using SublimeText
58+
# *.sublime-project
59+
60+
# Complexity
61+
output/*.html
62+
output/*/index.html
63+
64+
# Docs
65+
docs/_build
66+
_book/
67+
68+
# Secrets
69+
alembic.ini
70+
71+
# Module
72+
*.mod.yaml
73+
meta.yaml
74+
75+
# Local files
76+
local/
77+
78+
housekeeperold/
79+
testsold/

.github/workflows/build_and_publish.yml

+14
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,17 @@ jobs:
3838
with:
3939
user: __token__
4040
password: ${{ secrets.pypi_password }}
41+
42+
push_to_registry:
43+
name: Push Docker image to Docker Hub
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Check out the repo
47+
uses: actions/checkout@v2
48+
- name: Push to Docker Hub
49+
uses: docker/build-push-action@v1
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
repository: clinicalgenomics/housekeeper
54+
tag_with_ref: true

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ Please add a new candidate release at the top after changing the latest one. Fee
1212
### Changed
1313
### Fixed
1414

15+
## [3.1.0]
16+
17+
### Added
18+
19+
- Adds Dockerfile
20+
- Add workflow for automatic publish to docker-hub
21+
- Add __main__ script to run housekeeper without installing
22+
1523
## [3.0.1]
1624

1725
### Changed

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM python:3.7-slim
2+
3+
LABEL base_image="python:3.7-slim"
4+
LABEL software="housekeeper"
5+
LABEL about.summary="Image for housekeeper"
6+
LABEL about.home="https://github.com/Clinical-Genomics/housekeeper"
7+
LABEL about.documentation="https://github.com/Clinical-Genomics/housekeeper/README.md"
8+
LABEL about.license_file="https://github.com/Clinical-Genomics/housekeeper/LICENSE"
9+
LABEL about.license="MIT License (MIT)"
10+
LABEL about.tags="files,database"
11+
LABEL maintainer="Måns Magusson <[email protected]>"
12+
13+
RUN pip install -U pip
14+
# Avoid running as root for security reasons
15+
# More about that: https://pythonspeed.com/articles/root-capabilities-docker-security/
16+
# Solution inspired from
17+
# https://medium.com/@DahlitzF/run-python-applications-as-non-root-user-in-docker-containers-by-example-cba46a0ff384
18+
RUN useradd --create-home worker
19+
USER worker
20+
WORKDIR /home/worker
21+
22+
# Based on https://pythonspeed.com/articles/pipenv-docker/
23+
RUN pip install --user micropipenv pymysql cryptography
24+
# Update the path for micropipenv
25+
ENV PATH="/home/worker/.local/bin:${PATH}"
26+
27+
# Copy the lockfile to temporary directory. This will be deleted
28+
COPY --chown=worker:worker Pipfile.lock /tmp/
29+
# Generate reqs with locked dependencies for deterministic build
30+
RUN cd /tmp && micropipenv requirements > requirements.txt
31+
# Install deps
32+
RUN pip install --user -r /tmp/requirements.txt
33+
# Copy package
34+
COPY --chown=worker:worker . /tmp/housekeeper
35+
# Install package
36+
RUN pip install /tmp/housekeeper
37+
38+
ENTRYPOINT ["housekeeper"]
39+
CMD ["--help"]

Pipfile

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ python_version = "3.7"
2323

2424
[pipenv]
2525
allow_prereleases = true
26+
27+
[scripts]
28+
housekeeper = "python -m housekeeper"

housekeeper/__main__.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
housekeeper.__main__
3+
4+
The main entry point for the command line interface.
5+
6+
Invoke as `housekeeper` (if installed)
7+
or `python -m housekeeper` (no install required).
8+
"""
9+
import sys
10+
11+
from housekeeper.cli.core import base
12+
13+
if __name__ == "__main__":
14+
# exit using whatever exit code the CLI returned
15+
sys.exit(base())

0 commit comments

Comments
 (0)