Skip to content

Commit bfd9ab3

Browse files
authored
Add python 3.9 support (#8)
* add python 3.9 support * update dockerfile * fix prefix * publish latest only for defaut branch and latest python version * adapt github action titles * add 3.10 build to base layer * add latest versioned tag on main
1 parent 34ffb44 commit bfd9ab3

File tree

2 files changed

+54
-15
lines changed

2 files changed

+54
-15
lines changed
Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,68 @@
1-
name: Update Base Image for AWS Lambda and push to DockerHub
1+
name: Build and Push AWS Lambda Base Image
22

33
on:
44
push:
55
branches:
66
- main
7+
pull_request:
78
workflow_dispatch:
89

910
jobs:
1011
push_to_registry:
11-
name: Build and Push to DockerHub Registry
12+
name: Build and Push Docker Image
1213
runs-on: ubuntu-latest
13-
14+
strategy:
15+
matrix:
16+
python-version: ["3.8", "3.9", "3.10"]
17+
permissions:
18+
contents: read
19+
packages: write
20+
id-token: write
1421
steps:
1522
- name: Checkout
16-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
# - name: Log in to Docker Hub
28+
# uses: docker/login-action@v3
29+
# with:
30+
# username: ${{ secrets.DOCKER_USERNAME }}
31+
# password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Login to Github Packages
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
1739

18-
- name: Log in to Docker Hub
19-
uses: docker/login-action@v1
40+
- name: Extract Docker Metadata
41+
id: meta
42+
uses: docker/metadata-action@v5
2043
with:
21-
username: ${{ secrets.DOCKER_USERNAME }}
22-
password: ${{ secrets.DOCKER_PASSWORD }}
44+
flavor: |
45+
suffix=-${{ matrix.python-version }}
46+
tags: |
47+
type=schedule
48+
type=ref,event=branch
49+
type=ref,event=tag
50+
type=ref,event=pr
51+
type=raw,value=${{ matrix.python-version }},enable={{is_default_branch}}
52+
type=raw,value=latest,enable=${{ github.ref_name == github.event.repository.default_branch && matrix.python-version == '3.8' }}
53+
type=edge,branch=main,enable=false
54+
images: |
55+
name=${{ secrets.DOCKER_USERNAME }}/python-base-eval-layer,enable=false
56+
name=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
2357
2458
- name: Build and Push Base Image
25-
uses: docker/build-push-action@v2
59+
uses: docker/build-push-action@v5
2660
with:
2761
push: true
28-
tags: ${{ secrets.DOCKER_USERNAME }}/python-base-eval-layer
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
2964
build-args: |
65+
PYTHON_VERSION=${{ matrix.python-version }}
3066
INVOKER_ID=${{ secrets.INVOKER_ID }}
3167
INVOKER_KEY=${{ secrets.INVOKER_KEY }}
3268
INVOKER_REGION=${{ secrets.INVOKER_REGION }}

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1+
ARG PYTHON_VERSION
2+
13
# Base image is Python 3.8 provided by AWS Lambda in Docker Hub
2-
FROM public.ecr.aws/lambda/python:3.8
4+
FROM public.ecr.aws/lambda/python:${PYTHON_VERSION}
35

46
WORKDIR /app
57

68
# These are visible, the image is public so secrets would be accessible anyways
79
# We'd like these to be available if any evaluation function needs it...
8-
# TODO: Find a better way to do thi
10+
# TODO: ~Find a better way to do this~
11+
# TODO: We can probably use docker secrets, let's see...
912
ARG INVOKER_ID
1013
ARG INVOKER_KEY
1114
ARG INVOKER_REGION
1215

13-
ENV INVOKER_ID=${INVOKER_ID}\
14-
INVOKER_KEY=${INVOKER_KEY}\
15-
INVOKER_REGION=${INVOKER_REGION}
16+
ENV INVOKER_ID=${INVOKER_ID}
17+
ENV INVOKER_KEY=${INVOKER_KEY}
18+
ENV INVOKER_REGION=${INVOKER_REGION}
1619

1720
# Install backend dependencies
1821
COPY requirements.txt base_requirements.txt

0 commit comments

Comments
 (0)