Skip to content

Commit eb4e6bd

Browse files
committed
First version of Dockerfiles and setup.py
1 parent 8fa74f6 commit eb4e6bd

6 files changed

Lines changed: 123 additions & 2 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include README.md LICENSE

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Blueprint/Boilerplate For Golang Projects
1+
# Blueprint/Boilerplate For Python Projects
22

33
## Running
44

@@ -16,4 +16,5 @@ python3 -m blueprint
1616
### Resources
1717
- <https://realpython.com/python-application-layouts/>
1818
- <https://dev.to/codemouse92/dead-simple-python-project-structure-and-imports-38c6>
19-
- <https://github.com/navdeep-G/samplemod/blob/master/setup.py>
19+
- <https://github.com/navdeep-G/samplemod/blob/master/setup.py>
20+
- <https://github.com/GoogleContainerTools/distroless/blob/master/examples/python3/Dockerfile>

dev.Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.8-slim AS builder
2+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc
3+
4+
COPY requirements.txt .
5+
RUN pip install -r requirements.txt
6+
7+
COPY . .
8+
RUN python setup.py install
9+
10+
FROM python:3.8.1-alpine3.11 AS runner
11+
COPY --from=builder /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
12+
13+
CMD ["python", "-m", "blueprint"]
14+
15+
16+
# TODO add test run to this image build

prod.Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.5-slim AS builder
2+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc
3+
4+
COPY requirements.txt .
5+
RUN pip install -r requirements.txt
6+
7+
COPY . .
8+
RUN python setup.py install
9+
10+
FROM gcr.io/distroless/python3 as runner
11+
COPY --from=builder /usr/local/lib/python3.5/site-packages/ /usr/local/lib/python3.5/site-packages/
12+
13+
ENV PYTHONPATH=/usr/local/lib/python3.5/site-packages/blueprint-0.0.1-py3.5.egg
14+
ENTRYPOINT ["python", "-m", "blueprint"]
15+
16+
# TODO parametrize the version (Python and package version)
17+
# TODO add test run to this image build

setup.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import io
2+
import os
3+
4+
from setuptools import find_packages, setup
5+
6+
# Package meta-data.
7+
NAME = 'blueprint'
8+
DESCRIPTION = 'Blueprint/Boilerplate For Python Projects'
9+
URL = 'https://github.com/MartinHeinz/python-project-blueprint'
10+
EMAIL = 'martin7.heinz@gmail.com'
11+
AUTHOR = 'Martin Heinz'
12+
REQUIRES_PYTHON = '>=3.8.0'
13+
VERSION = '0.0.1'
14+
15+
# What packages are required for this module to be executed?
16+
REQUIRED = [
17+
'pytest',
18+
]
19+
20+
# What packages are optional?
21+
EXTRAS = {
22+
# 'fancy feature': ['django'],
23+
}
24+
25+
here = os.path.abspath(os.path.dirname(__file__))
26+
27+
# Import the README and use it as the long-description.
28+
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
29+
try:
30+
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
31+
long_description = '\n' + f.read()
32+
except FileNotFoundError:
33+
long_description = DESCRIPTION
34+
35+
# Load the package's __version__.py module as a dictionary.
36+
about = {}
37+
if not VERSION:
38+
project_slug = NAME.lower().replace("-", "_").replace(" ", "_")
39+
with open(os.path.join(here, project_slug, '__version__.py')) as f:
40+
exec(f.read(), about)
41+
else:
42+
about['__version__'] = VERSION
43+
44+
setup(
45+
name=NAME,
46+
version=about['__version__'],
47+
description=DESCRIPTION,
48+
long_description=long_description,
49+
long_description_content_type='text/markdown',
50+
author=AUTHOR,
51+
author_email=EMAIL,
52+
python_requires=REQUIRES_PYTHON,
53+
url=URL,
54+
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
55+
# If your package is a single module, use this instead of 'packages':
56+
# py_modules=['mypackage'],
57+
58+
# entry_points={
59+
# 'console_scripts': ['mycli=mymodule:cli'],
60+
# },
61+
install_requires=REQUIRED,
62+
extras_require=EXTRAS,
63+
include_package_data=True,
64+
license='MIT',
65+
classifiers=[
66+
# Trove classifiers
67+
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
68+
'License :: OSI Approved :: MIT License',
69+
'Programming Language :: Python',
70+
'Programming Language :: Python :: 3',
71+
'Programming Language :: Python :: 3.8',
72+
'Programming Language :: Python :: Implementation :: CPython',
73+
],
74+
)
75+
76+
# TODO add option to upload to PyPI

test.Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.8-slim AS builder
2+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc
3+
4+
COPY requirements.txt .
5+
RUN pip install -r requirements.txt
6+
7+
COPY . .
8+
9+
WORKDIR ./tests
10+
CMD ["pytest"]

0 commit comments

Comments
 (0)