FROM reg.cadoles.com/dh/library/golang:1.22-alpine AS build

ARG HTTP_PROXY=
ARG HTTPS_PROXY=
ARG http_proxy=
ARG https_proxy=

RUN apk update && apk add --no-cache build-base git bash curl python3 nodejs npm

COPY . /src

WORKDIR /src

RUN cp -f misc/docker/config-patch.yml misc/release/config-patch.yml

RUN go install github.com/krishicks/yaml-patch/cmd/yaml-patch@v0.0.10

RUN npm install \
    && make vendor \
    && echo "---" > ./misc/release/config-patch.yml \
    && make ARCH_TARGETS=amd64 release


FROM busybox

RUN adduser -D -h /app sms

COPY --from=build /src/release/fake-sms-linux-amd64 /app
RUN chown -R sms:sms /app

USER sms
WORKDIR /app

CMD ["bin/fake-sms", "--config", "config.yml"]