From 79c3913e28216040612a3be56d4d439f9f936217 Mon Sep 17 00:00:00 2001 From: ted-cdw Date: Tue, 21 Feb 2023 20:30:43 -0500 Subject: [PATCH] Add Dockerfile --- .github/workflows/flaskr-ci.yaml | 19 +++++++++---------- examples/tutorial/Dockerfile | 11 +++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 examples/tutorial/Dockerfile diff --git a/.github/workflows/flaskr-ci.yaml b/.github/workflows/flaskr-ci.yaml index 611c8a0c..30225258 100644 --- a/.github/workflows/flaskr-ci.yaml +++ b/.github/workflows/flaskr-ci.yaml @@ -42,7 +42,8 @@ jobs: - name: Job vars and prep id: vars # Use bash string manipulation to create vars - # Note runner.temp isn't available in job.env, so use it here + # Note runner context isn't available in job.env, so use it here + # https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#context-availability run: | echo "SHA_SHORT=${GITHUB_SHA:0:10}" >> ${GITHUB_ENV} echo "REPO_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} @@ -70,16 +71,14 @@ jobs: with: context: examples/tutorial push: true - # tags: "ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.sha_short }}" tags: "ghcr.io/${{ env.REPO_LOWER_CASE }}:${{ env.SHA_SHORT }}" cache-from: type=local,src=${{ env.CACHE }} cache-to: type=local,dest=${{ env.NEW_CACHE }} - # This ugly bit is necessary if you don't want your cache to grow forever - # until it hits GitHub's limit of 5GB. - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - - name: Move cache + # Only save the latest Docker build layers to the cache, otherwise + # the cache will keep growing indefinitely, past the 10GB max + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Only persist the new cache layers run: | - rm -rf $CACHE - mv $NEW_CACHE $CACHE + rm -rf ${CACHE) + mv ${NEW_CACHE} ${CACHE} diff --git a/examples/tutorial/Dockerfile b/examples/tutorial/Dockerfile new file mode 100644 index 00000000..cdeef98d --- /dev/null +++ b/examples/tutorial/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.11.2-alpine3.17 + +COPY . "/tutorial" +WORKDIR /tutorial + +RUN pip install . +RUN flask --app=flaskr init-db + +EXPOSE 5000 + +CMD [ "flask", "--app=flaskr", "run", "--host=0.0.0.0"] \ No newline at end of file