-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Dockerfile * make: add build-image * ci: add circle config to push images * update readme to use docker image
- Loading branch information
Showing
5 changed files
with
239 additions
and
49 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,90 @@ | ||
# These environment variables must be set in CircleCI UI | ||
# | ||
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo> | ||
# DOCKER_USER | ||
# DOCKER_PASS | ||
# | ||
version: 2.1 | ||
jobs: | ||
test: | ||
docker: | ||
- image: circleci/python:buster | ||
steps: | ||
- checkout | ||
- run: | ||
name: install python deps in venv | ||
command: | | ||
make install | ||
- run: | ||
name: run tests | ||
command: | | ||
make black check_conftest_imports test coverage | ||
build-image: | ||
docker: | ||
- image: circleci/python:buster | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- run: | ||
name: build-image | ||
command: make build-image | ||
- run: | ||
name: save built image to cache | ||
command: docker save "localhost/frost:latest" | gzip -c > /tmp/docker.tgz | ||
- save_cache: | ||
key: v1-{{ .Branch }}-{{ epoch }} | ||
paths: | ||
- /tmp/docker.tgz | ||
|
||
deploy: | ||
docker: | ||
- image: circleci/python:buster | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- restore_cache: | ||
key: v1-{{.Branch}} | ||
- run: | ||
name: Restore Docker image cache | ||
command: gunzip -c /tmp/docker.tgz | docker load | ||
- run: | ||
name: deploy to Dockerhub | ||
command: | | ||
# deploy master and scan envs | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
docker tag "localhost/frost:latest" "${DOCKERHUB_REPO}:latest" | ||
docker push "${DOCKERHUB_REPO}:latest" | ||
elif [ ! -z "${CIRCLE_TAG}" ]; then | ||
# deploy a release tag | ||
docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
echo "${DOCKERHUB_REPO}:${CIRCLE_TAG}" | ||
docker tag "localhost/frost:latest" "${DOCKERHUB_REPO}:${CIRCLE_TAG}" | ||
docker push "${DOCKERHUB_REPO}:${CIRCLE_TAG}" | ||
fi | ||
workflows: | ||
version: 2 | ||
check-readme-local-dev: | ||
jobs: | ||
- test: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
|
||
- build-image: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
|
||
- deploy: | ||
requires: | ||
- test | ||
- build-image | ||
filters: | ||
tags: | ||
# only upload the docker container on semver tags | ||
only: /[0-9]\.[0-9]+\.[0-9]+/ | ||
branches: | ||
only: master |
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,109 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# VCS | ||
.git | ||
|
||
# CI | ||
.circleci | ||
.travis.yml |
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,29 @@ | ||
# frost | ||
|
||
FROM python:3.8-slim-buster | ||
|
||
ENV PYTHONPATH $PYTHONPATH:/app | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN groupadd --gid 10001 app && \ | ||
useradd --uid 10001 --gid 10001 --shell /usr/sbin/nologin app | ||
RUN install -o app -g app -d /var/run/depobs /var/log/depobs | ||
|
||
# git for herokuadmintools | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install --no-install-recommends -y \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
jq | ||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt . | ||
RUN pip install --upgrade --no-cache-dir -r requirements.txt | ||
|
||
COPY * . | ||
|
||
USER app | ||
ENTRYPOINT [ ] |
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