build: add docker image build entrypoint
This commit is contained in:
parent
9a1331109f
commit
ff0860c6db
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
||||
.git
|
||||
.gitignore
|
||||
target
|
||||
tmp
|
||||
bin
|
||||
dist
|
||||
coverage
|
||||
**/.DS_Store
|
||||
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@ -0,0 +1,22 @@
|
||||
FROM golang:1.24 AS builder
|
||||
|
||||
ARG APP_VERSION="dev"
|
||||
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
|
||||
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN go build -trimpath -ldflags="-s -w" -o /out/chatapp3-golang ./cmd/api
|
||||
|
||||
FROM alpine:3.20
|
||||
|
||||
ARG APP_VERSION="dev"
|
||||
RUN apk add --no-cache ca-certificates wget
|
||||
|
||||
WORKDIR /application
|
||||
COPY --from=builder /out/chatapp3-golang /application/service
|
||||
|
||||
LABEL org.opencontainers.image.version="${APP_VERSION}"
|
||||
|
||||
RUN chmod +x /application/service
|
||||
|
||||
ENTRYPOINT ["/application/service"]
|
||||
15
ci/build-image.sh
Executable file
15
ci/build-image.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
IMAGE_REF="${1:-}"
|
||||
APP_VERSION="${APP_VERSION:-${2:-dev}}"
|
||||
DOCKER_PLATFORM="${DOCKER_PLATFORM:-linux/amd64}"
|
||||
|
||||
if [ -z "${IMAGE_REF}" ]; then
|
||||
echo "usage: ci/build-image.sh <image-ref> [app-version]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${ROOT_DIR}"
|
||||
docker build --platform "${DOCKER_PLATFORM}" --build-arg "APP_VERSION=${APP_VERSION}" -t "${IMAGE_REF}" .
|
||||
Loading…
x
Reference in New Issue
Block a user