Skip to content

Commit 6a263e8

Browse files
author
mike dupont
committed
adding docker build
1 parent 9a05f71 commit 6a263e8

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/image.yaml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
name: Create and publish a Docker image
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
pull_request:
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
ECR_REPOSITORY: nodemodules/tokenizer
13+
DOCKER_REPOSITORY: h4ckermike/arm64-tokenizers
14+
SESSION_APP_NAME: tokenizer
15+
16+
jobs:
17+
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
attestations: write
24+
id-token: write
25+
26+
steps:
27+
- name: Configure AWS credentials
28+
uses: meta-introspector/configure-aws-credentials@v4
29+
with:
30+
aws-region: ${{ secrets.AWS_REGION || 'us-east-2'}}
31+
role-session-name: github-actions-${{ env.SESSION_APP_NAME }}
32+
# FIXME hard coded
33+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID || '767503528736' }}:role/github
34+
35+
- name: Set up Docker Buildx
36+
uses: meta-introspector/setup-buildx-action@v3.8.0
37+
with:
38+
install: true
39+
platforms: linux/amd64,linux/arm/v7,linux/arm/v8
40+
41+
- name: Login to Amazon ECR
42+
id: login-ecr
43+
uses: meta-introspector/amazon-ecr-login@v1
44+
- uses: meta-introspector/create-ecr-repository-action@v1
45+
with:
46+
repository: ${{ env.ECR_REPOSITORY }}
47+
48+
- name: Set short sha
49+
id: sha_short
50+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
51+
52+
- name: Login to Docker Hub
53+
uses: meta-introspector/login-action@v3
54+
with:
55+
username: ${{ vars.DOCKER_HUB_USERNAME }}
56+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
57+
58+
- name: Checkout repository
59+
uses: meta-introspector/checkout@v4
60+
61+
- name: Log in to the Container registry
62+
uses: meta-introspector/login-action@v3.0.0
63+
with:
64+
registry: ${{ env.REGISTRY }}
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Extract metadata (tags, labels) for Docker
69+
id: meta
70+
uses: meta-introspector/metadata-action@v5.5.1
71+
with:
72+
images: |
73+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74+
${{ env.DOCKER_REPOSITORY}}
75+
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY}}
76+
77+
- name: Build and push Docker image
78+
id: push
79+
uses: meta-introspector/build-push-action@v6.10.0
80+
with:
81+
platforms: linux/arm64,linux/arm64/v8
82+
context: .
83+
push: true
84+
tags: |
85+
${{ steps.meta.outputs.tags }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
88+
- name: Generate artifact attestation
89+
uses: meta-introspector/attest-build-provenance@local
90+
with:
91+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
92+
subject-digest: ${{ steps.push.outputs.digest }}
93+
push-to-registry: true
94+
95+
- name: Make Docker image public
96+
run: |
97+
curl \
98+
-X PATCH \
99+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
100+
-H "Accept: application/vnd.github.v3+json" \
101+
https://api.github.com/user/packages/container/${{ env.IMAGE_NAME }}/visibility \
102+
-d '{"visibility":"public"}'

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#FROM node:23-slim AS base
2+
FROM arm64v8/node:23-bookworm-slim AS base
3+
ENV PNPM_HOME="/pnpm"
4+
ENV PATH="$PNPM_HOME:$PATH"
5+
RUN corepack enable
6+
COPY . /node_modules/fastembed
7+
WORKDIR /node_modules/fastembed
8+
9+
FROM base AS prod-deps
10+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
11+
12+
FROM base AS build
13+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
14+
RUN pnpm run tsc
15+
#RUN pnpm pack
16+
17+
FROM base
18+
COPY --from=prod-deps /node_modules/ /app/node_modules/
19+
COPY --from=build /node_modules/ /app/node_modules/

0 commit comments

Comments
 (0)