# syntax=docker/dockerfile:1

FROM golang:1.25-alpine AS build
WORKDIR /src

RUN apk add --no-cache ca-certificates

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

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/nomadcode-core ./cmd/server

FROM alpine:3.21
RUN apk add --no-cache ca-certificates git
RUN adduser -D -H appuser
WORKDIR /app

COPY --from=build /bin/nomadcode-core /usr/local/bin/nomadcode-core

USER appuser
EXPOSE 8080
ENTRYPOINT ["nomadcode-core"]
