Skip to content

Commit b836f88

Browse files
tarekbadrshafrittoli
authored andcommitted
add deployment files
1 parent e8a3342 commit b836f88

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM python:3.8
4+
5+
# Setup environment
6+
RUN apt-get update && apt-get install -y \
7+
python3-distutils \
8+
build-essential
9+
10+
# Copy requirements
11+
COPY ./requirements ./requirements
12+
13+
# Installing requirements
14+
RUN pip install -r ./requirements
15+
16+
# Copy needed files (see .dockerignore for what will be included)
17+
COPY . /cdevents-client
18+
19+
WORKDIR /cdevents-client
20+
21+
# Build
22+
RUN /bin/bash -c "make package-install"
23+
24+
WORKDIR /cdevents-client

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
include header.mk
2+
3+
PACKAGES = template core web cli
4+
export ABS_ROOT_PATH=$(shell pwd)
5+
6+
.PHONY: packages $(PACKAGES)
7+
8+
packages: $(PACKAGES)
9+
10+
$(PACKAGES):
11+
$(MAKE) -C $@
12+
13+
# the sets of directories to do various things in
14+
INITPACKAGES = $(PACKAGES:%=init-%)
15+
INSTALLPACKAGES = $(PACKAGES:%=package-install-%)
16+
CLEANPACKAGES = $(PACKAGES:%=clean-%)
17+
TESTPACKAGES = $(PACKAGES:%=test-%)
18+
LINTPACKAGES = $(PACKAGES:%=lint-%)
19+
FORMATPACKAGES = $(PACKAGES:%=format-%)
20+
BUMPVERSIONPACKAGES = $(PACKAGES:%=bumpversion-%)
21+
22+
help: ## Prints this help text
23+
@python -c "$$PRINT_HELP_PYSCRIPT" < Makefile
24+
25+
init: $(INITPACKAGES) ## Installs all packages in editable mode including dev dependencies
26+
$(INITPACKAGES):
27+
$(MAKE) -C $(@:init-%=%) init
28+
29+
package-install: $(INSTALLPACKAGES) ## Installs all packages without dev dependencies
30+
$(INSTALLPACKAGES):
31+
$(MAKE) -C $(@:package-install-%=%) package-install
32+
33+
test: $(TESTPACKAGES) ## Run tests on all packages
34+
$(TESTPACKAGES):
35+
$(MAKE) -C $(@:test-%=%) test
36+
37+
clean: $(CLEANPACKAGES) ## Remove all build, test, coverage and Python artifacts
38+
$(CLEANPACKAGES):
39+
$(MAKE) -C $(@:clean-%=%) clean
40+
41+
bumpversion: ${BUMPVERSIONPACKAGES} ## Bumps the (default: patch) version of all release packages. To bump minor or major, add bump=minor or bump=major to the make call.
42+
$(BUMPVERSIONPACKAGES):
43+
$(MAKE) -C $(@:bumpversion-%=%) bumpversion
44+
45+
lint: $(LINTPACKAGES)
46+
$(LINTPACKAGES):
47+
$(MAKE) -C $(@:lint-%=%) lint
48+
49+
format: $(FORMATPACKAGES)
50+
$(FORMATPACKAGES):
51+
$(MAKE) -C $(@:format-%=%) format
52+
53+
install: ## Installs dependencies from requirements.txt
54+
pip install -r ./requirements
55+
pre-commit install
56+
57+
internal-install: ## Installs VCC-internal dependencies from vcc-requirements.txt
58+
pip install --extra-index-url https://TODO -r vccinternal-requirements.txt
59+
60+
check: ## Runs pre-commit hooks on all files
61+
pre-commit run --all-files
62+
63+
docker-build: ## Build and package Docker container
64+
docker build -t cdevents-client -f Dockerfile .
65+
66+
docker-shell: ## Opens a shell
67+
docker run --add-host=host.docker.internal:host-gateway --volume /"$(shell pwd)"/output/:/root/cdevents-client/ -it cdevents-client bash
68+
69+
.PHONY: packages $(PACKAGES)
70+
.PHONY: packages $(INITPACKAGES)
71+
.PHONY: packages $(INSTALLPACKAGES)
72+
.PHONY: packages $(TESTPACKAGES)
73+
.PHONY: packages $(CLEANPACKAGES)
74+
.PHONY: packages $(BUMPVERSIONPACKAGES)
75+
.PHONY: init test clean bumpversion install internal-install check docker-build docker-shell

header.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.PHONY: clean clean-test clean-pyc clean-build help
2+
.DEFAULT_GOAL := help
3+
4+
define BROWSER_PYSCRIPT
5+
import os, webbrowser, sys
6+
7+
try:
8+
from urllib import pathname2url
9+
except:
10+
from urllib.request import pathname2url
11+
12+
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
13+
endef
14+
export BROWSER_PYSCRIPT
15+
16+
define PRINT_HELP_PYSCRIPT
17+
import re, sys
18+
19+
for line in sys.stdin:
20+
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
21+
if match:
22+
target, help = match.groups()
23+
print("%-20s %s" % (target, help))
24+
endef
25+
export PRINT_HELP_PYSCRIPT
26+
27+
BROWSER := python -c "$$BROWSER_PYSCRIPT"

targets.mk

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
help:
2+
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
3+
4+
init: clean ## install the package in editable mode including dev dependencies
5+
pip install -e .[dev]
6+
pre-commit install
7+
8+
package-install: ## install the package without dev dependencies
9+
pip install .
10+
11+
test: ## run tests quickly with the default Python
12+
python -m pytest -m unit
13+
14+
dist: clean ## builds source and wheel package
15+
python setup.py sdist
16+
python setup.py bdist_wheel
17+
ls -l dist
18+
19+
format: ## format all Python code using black
20+
python -m black --line-length=100 .
21+
22+
.ONESHELL:
23+
lint: ## run pylint
24+
python -m pylint $(SRC) --rcfile=$(ABS_ROOT_PATH)/.pylintrc
25+
exit_code=$$?
26+
python -m pylint \
27+
--disable duplicate-code \
28+
--disable missing-module-docstring \
29+
--disable missing-function-docstring \
30+
tests --rcfile=$(ABS_ROOT_PATH)/.pylintrc
31+
exit_code=`expr $${exit_code} + $$?`
32+
if [ "$${exit_code}" != 0 ]; then
33+
exit "$${exit_code}"
34+
fi
35+
36+
clean: clean-build clean-pyc clean-test clean-mypy ## remove all build, test, coverage and Python artifacts
37+
38+
clean-build: ## remove build artifacts
39+
rm -fr build/
40+
rm -fr dist/
41+
rm -fr .eggs/
42+
# N.B. line below removes editable intallation of package in venv
43+
# find . -name '*.egg-info' -exec rm -fr {} +
44+
find . -name '*.egg' -exec rm -f {} +
45+
46+
clean-pyc: ## remove Python file artifacts
47+
find . -name '*.pyc' -exec rm -f {} +
48+
find . -name '*.pyo' -exec rm -f {} +
49+
find . -name '*~' -exec rm -f {} +
50+
find . -name '__pycache__' -exec rm -fr {} +
51+
52+
clean-test: ## remove test and coverage artifacts
53+
rm -f .coverage
54+
rm -fr htmlcov/
55+
rm -fr .pytest_cache
56+
57+
clean-mypy: ## remove MyPy cache files
58+
rm -fr .mypy_cache/
59+
60+
bump = patch
61+
bumpversion: ## Bumps the (default: patch) version of this package. To bump minor or major, add bump=minor or bump=major to the make call.
62+
bumpversion --allow-dirty $(bump)
63+
- pre-commit run trailing-whitespace --file setup.cfg
64+
- pre-commit run remove-tabs --file setup.cfg
65+
66+
67+
.ONESHELL:
68+
pre-commit:
69+
pre-commit run --all-files

0 commit comments

Comments
 (0)