From f0868ad5e9168bb1c5d45b1c8a462a34eb35b3ba Mon Sep 17 00:00:00 2001 From: Josh Waller Date: Sat, 28 Mar 2020 17:46:33 -0400 Subject: [PATCH 1/4] Adding initial Dockerfile --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e25ec51 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python3.7-slim as base + +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONFAULTHANDLER 1 + +FROM base AS python-deps + +RUN pip install pipenv +RUN apt-get update && apt-get install -y --no-install-recommends gcc + +COPY Pipfile . +COPY Pipfile.lock . +RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy + +FROM base AS runtime + +COPY --from=python-deps /.venv /.venv +ENV PATH="/.venv/bin:$PATH" + +RUN useradd --create-home appuser +WORKDIR /home/appuser +USER appuser + +COPY . . + +# Run fastic +CMD ["python", "fastic.py"] From e0b03aea3bfbd68abcb401707d4a73ab78a6e610 Mon Sep 17 00:00:00 2001 From: Josh Waller Date: Sat, 28 Mar 2020 23:57:20 -0400 Subject: [PATCH 2/4] dockerignore --- .dockerignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..10910fa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# Ignore everything +** + +# ... except for dependencies and source +!Pipfile +!Pipfile.lock +!my_package/ \ No newline at end of file From ae0fdea4f0ad786f979a7a4a3485af6b583cdfb9 Mon Sep 17 00:00:00 2001 From: Josh Waller Date: Sun, 29 Mar 2020 01:00:48 -0400 Subject: [PATCH 3/4] more testing --- .dockerignore | 10 +++++++++- Dockerfile | 26 +++++++++++--------------- docker-compose.yml | 11 +++++++++++ fastic.py | 2 +- 4 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore index 10910fa..7da7107 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,12 @@ # ... except for dependencies and source !Pipfile !Pipfile.lock -!my_package/ \ No newline at end of file + +# these will need removed once in package setup +!assets/ +!pages/ +!templates/ +!fastic.py +!config.py +!runtime.txt +!.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e25ec51..4a6e612 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,25 @@ -FROM python3.7-slim as base +FROM python:3.7-slim ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONFAULTHANDLER 1 -FROM base AS python-deps +COPY ./Pipfile /app/Pipfile +COPY ./Pipfile.lock /app/Pipfile.lock -RUN pip install pipenv -RUN apt-get update && apt-get install -y --no-install-recommends gcc - -COPY Pipfile . -COPY Pipfile.lock . -RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy +WORKDIR /app -FROM base AS runtime +RUN apt-get update && apt-get install -y --no-install-recommends gcc -COPY --from=python-deps /.venv /.venv -ENV PATH="/.venv/bin:$PATH" +RUN pip install pipenv +RUN pipenv install --dev -RUN useradd --create-home appuser -WORKDIR /home/appuser -USER appuser +COPY . /app -COPY . . +EXPOSE 80 # Run fastic +ENTRYPOINT ["pipenv", "run"] + CMD ["python", "fastic.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a8b51e4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' +services: + web: + build: . + ports: + - "5000:5000" + volumes: + - .:/app + environment: + FLASK_ENV: development + command: pipenv run python fastic.py diff --git a/fastic.py b/fastic.py index b65e771..0e52767 100644 --- a/fastic.py +++ b/fastic.py @@ -102,7 +102,7 @@ def run_dev(): server.watch('./templates', build_pages) server.watch('./assets/sass', build_styles) server.watch('./assets/js', build_js) - server.serve(root='build', port=5555) + server.serve(root='build', port=5000) if __name__ == '__main__': From 0b884522387c052ffa6a6234afa81a539c559072 Mon Sep 17 00:00:00 2001 From: Josh Waller Date: Sun, 29 Mar 2020 13:24:18 -0400 Subject: [PATCH 4/4] fixing docker setup and dev server --- Dockerfile | 2 -- fastic.py | 2 +- templates/base.html | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a6e612..00452ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,6 @@ RUN pipenv install --dev COPY . /app -EXPOSE 80 - # Run fastic ENTRYPOINT ["pipenv", "run"] diff --git a/fastic.py b/fastic.py index 0e52767..4c9b0bf 100644 --- a/fastic.py +++ b/fastic.py @@ -102,7 +102,7 @@ def run_dev(): server.watch('./templates', build_pages) server.watch('./assets/sass', build_styles) server.watch('./assets/js', build_js) - server.serve(root='build', port=5000) + server.serve(root='build', host="0.0.0.0", port=5000) if __name__ == '__main__': diff --git a/templates/base.html b/templates/base.html index 209d626..ab92506 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,7 @@ - Fastic + Fastic - python static site generator