ci: use AWS ECR Public base images for lti builds

This commit is contained in:
M1 AIR
2026-03-08 23:55:20 +07:00
parent e80874bad7
commit e6159e4f90
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -59,6 +59,9 @@ build_mr:
- *ecr_login - *ecr_login
script: | script: |
set -eu set -eu
# force base image pulls via AWS ECR Public to avoid Docker Hub TLS timeout
sed -i 's|^FROM golang:1.23-alpine AS builder$|FROM public.ecr.aws/docker/library/golang:1.23-alpine AS builder|' Dockerfile
sed -i 's|^FROM alpine:3.20$|FROM public.ecr.aws/docker/library/alpine:3.20|' Dockerfile
echo "Build (MR) : $ECR_REPOSITORY:$IMAGE_TAG" echo "Build (MR) : $ECR_REPOSITORY:$IMAGE_TAG"
docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" . docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" .
echo "Pushing image for MR..." echo "Pushing image for MR..."
@@ -82,6 +85,9 @@ build_push_dev:
- *ecr_login - *ecr_login
script: | script: |
set -eu set -eu
# force base image pulls via AWS ECR Public to avoid Docker Hub TLS timeout
sed -i 's|^FROM golang:1.23-alpine AS builder$|FROM public.ecr.aws/docker/library/golang:1.23-alpine AS builder|' Dockerfile
sed -i 's|^FROM alpine:3.20$|FROM public.ecr.aws/docker/library/alpine:3.20|' Dockerfile
echo "Build & push (dev): $ECR_REPOSITORY:$IMAGE_TAG" echo "Build & push (dev): $ECR_REPOSITORY:$IMAGE_TAG"
docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" . docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" .
docker push "$ECR_REPOSITORY:$IMAGE_TAG" docker push "$ECR_REPOSITORY:$IMAGE_TAG"
@@ -138,6 +144,9 @@ build_push_prod:
- *ecr_login - *ecr_login
script: | script: |
set -eu set -eu
# force base image pulls via AWS ECR Public to avoid Docker Hub TLS timeout
sed -i 's|^FROM golang:1.23-alpine AS builder$|FROM public.ecr.aws/docker/library/golang:1.23-alpine AS builder|' Dockerfile
sed -i 's|^FROM alpine:3.20$|FROM public.ecr.aws/docker/library/alpine:3.20|' Dockerfile
echo "Build & push (prod): $ECR_REPOSITORY:$IMAGE_TAG" echo "Build & push (prod): $ECR_REPOSITORY:$IMAGE_TAG"
docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" . docker build --platform "$TARGET_PLATFORM" -f Dockerfile -t "$ECR_REPOSITORY:$IMAGE_TAG" .
docker push "$ECR_REPOSITORY:$IMAGE_TAG" docker push "$ECR_REPOSITORY:$IMAGE_TAG"
+2 -2
View File
@@ -1,7 +1,7 @@
# ========================= # =========================
# Builder stage # Builder stage
# ========================= # =========================
FROM golang:1.23-alpine AS builder FROM public.ecr.aws/docker/library/golang:1.23-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /app WORKDIR /app
@@ -25,7 +25,7 @@ RUN GOBIN=/usr/local/bin go install -tags "postgres file" -ldflags="-s -w" githu
# ========================= # =========================
# Runtime stage # Runtime stage
# ========================= # =========================
FROM alpine:3.20 FROM public.ecr.aws/docker/library/alpine:3.20
RUN apk add --no-cache ca-certificates tzdata curl bash postgresql-client \ RUN apk add --no-cache ca-certificates tzdata curl bash postgresql-client \
&& adduser -D -H -u 10001 appuser && adduser -D -H -u 10001 appuser