Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
fi

echo "name=$image_name" >> "$GITHUB_OUTPUT"
echo "manifest=$image_name:${image_tags[0]}" >> "$GITHUB_OUTPUT"
{
echo "tags<<EOF"
printf '%s\n' "${image_tags[@]}"
Expand All @@ -67,12 +68,9 @@ jobs:
podman build \
--build-arg "SERVICE=$SERVICE" \
--label "org.opencontainers.image.source=https://github.com/$GITHUB_REPOSITORY" \
--tag "$image_name:${image_tags[0]}" \
--manifest "$image_name:${image_tags[0]}" \
--platform linux/amd64,linux/arm64 \
.

for image_tag in "${image_tags[@]:1}"; do
podman tag "$image_name:${image_tags[0]}" "$image_name:$image_tag"
done
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
REF_NAME: ${{ github.ref_name }}
Expand All @@ -90,9 +88,11 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
IMAGE_NAME: ${{ steps.image.outputs.name }}
IMAGE_MANIFEST: ${{ steps.image.outputs.manifest }}
IMAGE_TAGS: ${{ steps.image.outputs.tags }}
shell: bash
run: |
while IFS= read -r image_tag; do
[[ -n "$image_tag" ]] && podman push "$IMAGE_NAME:$image_tag"
[[ -n "$image_tag" ]] &&
podman manifest push --all "$IMAGE_MANIFEST" "docker://$IMAGE_NAME:$image_tag"
done <<< "$IMAGE_TAGS"
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
ARG GO_VERSION=1.26

FROM golang:${GO_VERSION}-alpine AS build
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
ARG SERVICE
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go run github.com/swaggo/swag/cmd/swag@v1.8.1 init -g cmd/api-service/main.go --parseInternal --output docs \
&& CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/service ./cmd/${SERVICE}
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" -o /out/service ./cmd/${SERVICE}

FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=build /out/service /service
Expand Down
2 changes: 1 addition & 1 deletion cmd/api-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// @title TrustPkg API
// @version 2.0.1
// @version 2.0.2
// @description API for searching npm packages and their vulnerability data.
// @BasePath /api
// @schemes http https
Expand Down
Loading