diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..67d0e5d4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +.venv +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.gitignore +.github +.gitattributes +*.egg-info +.mypy_cache +.pytest_cache +.hypothesis +build diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..6fb3dc2d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +IMAGE=terracotta +VERSION=<> + +all: build push + +build: + docker build -f ./docker/Dockerfile -t $(IMAGE):$(VERSION) . + +push: + docker push $(IMAGE):$(VERSION) + +.PHONY: build push all diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..3e3d7b35 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.10.12-slim-bullseye as build_tarball + +RUN apt-get update \ + && apt-get install \ + -y --no-install-recommends \ + build-essential \ + git \ + && rm -rf /var/lib/apt/lists/* + +COPY ./ /terracotta +COPY ./docker/entrypoint.sh /entrypoint.sh + +WORKDIR /terracotta + +RUN python -m pip install --upgrade pip \ + && python setup.py sdist + + +FROM python:3.10.12-slim-bullseye + +COPY --from=build_tarball /terracotta/dist/terracotta-*.tar.gz /terracotta/terracotta.tar.gz +COPY --from=build_tarball /entrypoint.sh /entrypoint.sh + +RUN pip install --upgrade pip \ + && pip install psycopg2-binary \ + && pip install /terracotta/terracotta.tar.gz \ + && rm -rf /terracotta + +ENV TC_SERVER_PORT=5000 +EXPOSE $TC_SERVER_PORT + +CMD ["/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..c966f89b --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +terracotta serve --allow-all-ips --port $TC_SERVER_PORT -d $TC_DRIVER_PATH