~jgillis/python-flask-cookiecutter

8d04be28ee24af0543fad96a9bd5437c4ccef88a — Joris Gillis 3 years ago 9c567ae
Producing a docker image

A docker image running a uWSGI container with your package included.
M {{ cookiecutter.python_package_name }}/Makefile => {{ cookiecutter.python_package_name }}/Makefile +6 -0
@@ 24,6 24,12 @@ lint:
build: test lint
	poetry build

docker: build
	cp dist/{{ cookiecutter.python_package_name }}*.whl docker/
	cd docker && docker build -t {{ cookiecutter.python_package_name }} .
	docker save {{ cookiecutter.python_package_name }} >dist/{{ cookiecutter.python_package_name }}-`ls docker/*.whl | grep -o -E "[0-9\.]+(post[0-9]+\.dev[0-9]+\+[a-f0-9]+)?" | head -n 1`.tar
	rm docker/*.whl

autodocs:
	sphinx-apidoc -f -o docs {{ cookiecutter.module_name }}


A {{ cookiecutter.python_package_name }}/docker/Dockerfile => {{ cookiecutter.python_package_name }}/docker/Dockerfile +16 -0
@@ 0,0 1,16 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

EXPOSE 5000

RUN microdnf update && \
    microdnf install python38 python38-devel gcc shadow-utils && \
    useradd -ms /bin/bash python

USER python
WORKDIR /home/python

COPY *.whl .
RUN pip3 install --user *.whl && \
    pip3 install --user uwsgi

CMD ["/home/python/.local/bin/uwsgi", "--http", "0.0.0.0:5000", "-T", "--module", "{{ cookiecutter.module_name }}.app:app"]
\ No newline at end of file