2018-01-02 16:11:59 +00:00
|
|
|
#########################################
|
|
|
|
# Build stage
|
|
|
|
#########################################
|
2022-10-26 06:35:13 +00:00
|
|
|
FROM golang:1.19 AS builder
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Repository location
|
|
|
|
ARG REPOSITORY=github.com/ncarlier
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Artifact name
|
|
|
|
ARG ARTIFACT=webhookd
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Copy sources into the container
|
|
|
|
ADD . /go/src/$REPOSITORY/$ARTIFACT
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Set working directory
|
|
|
|
WORKDIR /go/src/$REPOSITORY/$ARTIFACT
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Build the binary
|
|
|
|
RUN make
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
#########################################
|
|
|
|
# Distribution stage
|
|
|
|
#########################################
|
2022-08-25 21:06:54 +00:00
|
|
|
FROM alpine:latest AS slim
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Repository location
|
|
|
|
ARG REPOSITORY=github.com/ncarlier
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Artifact name
|
|
|
|
ARG ARTIFACT=webhookd
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
# User
|
|
|
|
ARG USER=webhookd
|
|
|
|
ARG UID=1000
|
2020-03-15 23:07:38 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
# Create non-root user
|
|
|
|
RUN adduser \
|
|
|
|
--disabled-password \
|
|
|
|
--gecos "" \
|
|
|
|
--home "$(pwd)" \
|
|
|
|
--no-create-home \
|
|
|
|
--uid "$UID" \
|
|
|
|
"$USER"
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2018-01-05 14:37:50 +00:00
|
|
|
# Install deps
|
2022-08-25 21:06:54 +00:00
|
|
|
RUN apk add --no-cache bash gcompat
|
2018-05-06 09:00:27 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
# Install binary
|
|
|
|
COPY --from=builder /go/src/$REPOSITORY/$ARTIFACT/release/$ARTIFACT /usr/local/bin/$ARTIFACT
|
|
|
|
|
|
|
|
VOLUME [ "/scripts" ]
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
USER $USER
|
|
|
|
|
|
|
|
CMD [ "webhookd" ]
|
2019-03-29 09:27:01 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
#########################################
|
|
|
|
# Distribution stage with some tooling
|
|
|
|
#########################################
|
|
|
|
FROM alpinelinux/docker-cli:latest AS distrib
|
|
|
|
|
|
|
|
# Repository location
|
|
|
|
ARG REPOSITORY=github.com/ncarlier
|
2018-01-05 14:37:50 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
# Artifact name
|
|
|
|
ARG ARTIFACT=webhookd
|
|
|
|
|
|
|
|
# User
|
|
|
|
ARG USER=webhookd
|
|
|
|
ARG UID=1000
|
|
|
|
|
|
|
|
# Create non-root user
|
|
|
|
RUN adduser \
|
|
|
|
--disabled-password \
|
|
|
|
--gecos "" \
|
|
|
|
--home "$(pwd)" \
|
|
|
|
--no-create-home \
|
|
|
|
--uid "$UID" \
|
|
|
|
"$USER"
|
|
|
|
|
|
|
|
# Install deps
|
|
|
|
RUN apk add --no-cache bash gcompat git openssh-client curl jq
|
|
|
|
|
|
|
|
# Install docker-compose
|
|
|
|
RUN curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh \
|
|
|
|
-o /usr/local/bin/docker-compose && \
|
|
|
|
chmod +x /usr/local/bin/docker-compose
|
|
|
|
|
|
|
|
# Install binary and entrypoint
|
2019-01-09 10:25:51 +00:00
|
|
|
COPY --from=builder /go/src/$REPOSITORY/$ARTIFACT/release/$ARTIFACT /usr/local/bin/$ARTIFACT
|
2018-07-06 14:07:09 +00:00
|
|
|
COPY docker-entrypoint.sh /
|
|
|
|
|
2018-07-06 14:10:53 +00:00
|
|
|
# Define entrypoint
|
2018-07-06 14:07:09 +00:00
|
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
2014-09-23 18:21:43 +00:00
|
|
|
|
2022-08-25 21:06:54 +00:00
|
|
|
VOLUME [ "/scripts" ]
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
USER $USER
|
|
|
|
|
|
|
|
CMD [ "webhookd" ]
|