Add Dockerfile

This commit is contained in:
ted-cdw 2023-02-21 20:30:43 -05:00
parent ca57a23f9d
commit 79c3913e28
2 changed files with 20 additions and 10 deletions

View file

@ -42,7 +42,8 @@ jobs:
- name: Job vars and prep - name: Job vars and prep
id: vars id: vars
# Use bash string manipulation to create 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: | run: |
echo "SHA_SHORT=${GITHUB_SHA:0:10}" >> ${GITHUB_ENV} echo "SHA_SHORT=${GITHUB_SHA:0:10}" >> ${GITHUB_ENV}
echo "REPO_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} echo "REPO_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
@ -70,16 +71,14 @@ jobs:
with: with:
context: examples/tutorial context: examples/tutorial
push: true push: true
# tags: "ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.sha_short }}"
tags: "ghcr.io/${{ env.REPO_LOWER_CASE }}:${{ env.SHA_SHORT }}" tags: "ghcr.io/${{ env.REPO_LOWER_CASE }}:${{ env.SHA_SHORT }}"
cache-from: type=local,src=${{ env.CACHE }} cache-from: type=local,src=${{ env.CACHE }}
cache-to: type=local,dest=${{ env.NEW_CACHE }} cache-to: type=local,dest=${{ env.NEW_CACHE }}
# This ugly bit is necessary if you don't want your cache to grow forever # Only save the latest Docker build layers to the cache, otherwise
# until it hits GitHub's limit of 5GB. # the cache will keep growing indefinitely, past the 10GB max
# Temp fix
# https://github.com/docker/build-push-action/issues/252 # https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896 # https://github.com/moby/buildkit/issues/1896
- name: Move cache - name: Only persist the new cache layers
run: | run: |
rm -rf $CACHE rm -rf ${CACHE)
mv $NEW_CACHE $CACHE mv ${NEW_CACHE} ${CACHE}

View file

@ -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"]