diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d17dae --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12bdf20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM alpine:latest AS base +LABEL org.opencontainers.image.authors=oggioni.walter@gmail.com +RUN --mount=type=cache,target=/var/cache/apk apk update +RUN --mount=type=cache,target=/var/cache/apk apk add python3 py3-pip uwsgi uwsgi-python3 graphviz uwsgi-gevent3 + +FROM base AS build +RUN adduser -D luser +USER luser +WORKDIR /home/luser +COPY --chown=luser:users ./requirements-dev.txt ./md2html/requirements-dev.txt +COPY --chown=luser:users ./src ./md2html/src +COPY --chown=luser:users ./pyproject.toml ./md2html/pyproject.toml +WORKDIR /home/luser/md2html +RUN python -m venv venv +RUN --mount=type=cache,target=/home/luser/.cache/pip,uid=1000,gid=1000 venv/bin/pip install -r requirements-dev.txt +RUN --mount=type=cache,target=/home/luser/.cache/pip,uid=1000,gid=1000 venv/bin/python -m build + +FROM base AS release +RUN mkdir /srv/http +RUN adduser -D -h /var/md2html -u 1000 md2html +USER md2html +WORKDIR /var/md2html +RUN python -m venv venv +RUN --mount=type=cache,target=/var/md2html/.cache/pip,uid=1000,gid=1000 --mount=type=cache,ro,from=build,source=/home/luser/md2html/dist,target=/dist venv/bin/pip install /dist/*.whl +COPY --chown=md2html:users conf/uwsgi.ini /var/md2html/ + +VOLUME /srv/http +WORKDIR /srv/http +ENTRYPOINT ["uwsgi"] +EXPOSE 1910/tcp +EXPOSE 1910/udp +CMD [ "--ini", "/var/md2html/uwsgi.ini" ] + + diff --git a/docker/uwsgi.ini b/conf/uwsgi.ini similarity index 85% rename from docker/uwsgi.ini rename to conf/uwsgi.ini index a2f270f..0098dee 100644 --- a/docker/uwsgi.ini +++ b/conf/uwsgi.ini @@ -2,7 +2,7 @@ #logformat = "%(proto) - %(method) %(uri) %(status) %(addr) need-plugin=/usr/lib/uwsgi/python_plugin.so need-plugin=/usr/lib/uwsgi/gevent3_plugin.so -socket = :1910 +socket = 0.0.0.0:1910 module = md2html.uwsgi_handler virtualenv = /var/md2html/venv -gevent = 1000 \ No newline at end of file +gevent = 1000 diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 3966a7f..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM alpine:latest -MAINTAINER Oggioni Walter -RUN apk update -RUN apk add python3 py3-pip uwsgi uwsgi-python3 graphviz uwsgi-gevent3 -RUN mkdir /srv/http -RUN mkdir /var/md2html -WORKDIR /var/md2html -RUN python -m venv venv -ADD uwsgi.ini /var/md2html -ADD md2html-*.whl / -RUN venv/bin/pip install /md2html-*.whl && rm /md2html-*.whl -VOLUME /srv/http -WORKDIR /srv/http -ENTRYPOINT ["uwsgi"] -EXPOSE 1910/tcp -EXPOSE 1910/udp -USER nobody -CMD [ "--ini", "/var/md2html/uwsgi.ini" ] - - diff --git a/pyproject.toml b/pyproject.toml index b6a67e6..5030abb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,11 @@ dependencies = [ "zope.interface" ] +[project.optional-dependencies] +dev = [ + "build", "pip-tools", "mypy", "ipdb" +] + [tool.setuptools.package-data] md2html = ['static/*'] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..658000f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,103 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml +# +--index-url https://gitea.woggioni.net/api/packages/woggioni/pypi/simple/ +--extra-index-url https://pypi.org/simple + +asttokens==2.4.1 + # via stack-data +build==1.2.1 + # via + # md2html (pyproject.toml) + # pip-tools +click==8.1.7 + # via pip-tools +decorator==5.1.1 + # via + # ipdb + # ipython +exceptiongroup==1.2.2 + # via ipython +executing==2.0.1 + # via stack-data +gevent==24.2.1 + # via md2html (pyproject.toml) +greenlet==3.0.3 + # via + # gevent + # md2html (pyproject.toml) +ipdb==0.13.13 + # via md2html (pyproject.toml) +ipython==8.26.0 + # via ipdb +jedi==0.19.1 + # via ipython +markdown==3.6 + # via md2html (pyproject.toml) +matplotlib-inline==0.1.7 + # via ipython +mypy==1.11.1 + # via md2html (pyproject.toml) +mypy-extensions==1.0.0 + # via mypy +packaging==24.1 + # via build +parso==0.8.4 + # via jedi +pexpect==4.9.0 + # via ipython +pip-tools==7.4.1 + # via md2html (pyproject.toml) +prompt-toolkit==3.0.47 + # via ipython +ptyprocess==0.7.0 + # via pexpect +pure-eval==0.2.3 + # via stack-data +pygments==2.18.0 + # via + # ipython + # md2html (pyproject.toml) +pyproject-hooks==1.1.0 + # via + # build + # pip-tools +six==1.16.0 + # via asttokens +stack-data==0.6.3 + # via ipython +tomli==2.0.1 + # via + # build + # ipdb + # mypy + # pip-tools +traitlets==5.14.3 + # via + # ipython + # matplotlib-inline +typing-extensions==4.12.2 + # via + # ipython + # mypy +watchdog==4.0.2 + # via md2html (pyproject.toml) +wcwidth==0.2.13 + # via prompt-toolkit +wheel==0.44.0 + # via pip-tools +zope-event==5.0 + # via + # gevent + # md2html (pyproject.toml) +zope-interface==7.0.1 + # via + # gevent + # md2html (pyproject.toml) + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/requirements.txt b/requirements.txt index 01d660c..e696ed9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,32 @@ -build==1.0.3 +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile --output-file=requirements.txt --strip-extras pyproject.toml +# +--index-url https://gitea.woggioni.net/api/packages/woggioni/pypi/simple/ +--extra-index-url https://pypi.org/simple + gevent==23.9.1 + # via md2html (pyproject.toml) greenlet==3.0.0 -Markdown==3.5 -packaging==23.2 -Pygments==2.16.1 -pyproject_hooks==1.0.0 + # via + # gevent + # md2html (pyproject.toml) +markdown==3.5 + # via md2html (pyproject.toml) +pygments==2.16.1 + # via md2html (pyproject.toml) watchdog==3.0.0 -zope.event==5.0 -zope.interface==6.1 + # via md2html (pyproject.toml) +zope-event==5.0 + # via + # gevent + # md2html (pyproject.toml) +zope-interface==6.1 + # via + # gevent + # md2html (pyproject.toml) + +# The following packages are considered to be unsafe in a requirements file: +# setuptools