api/Dockerfile
Peter Kurfer 7c2a41ad25 Move TLS/cert handling to main app
- apply changes in proxy plugin and TLS interceptor
- add HTTPS proxy support
- move ca-generation command to main app
- minor refactoring to improve API stability
- move mocks to extra packages to avoid cycling imports
- fix bug in multi-port configuration
- change HTTP proxy to redirect to HTTP mock instead of maintaining custom rules
2020-04-26 00:32:46 +02:00

45 lines
877 B
Docker

FROM golang:1.14-buster as build
# Create appuser.
ARG USER=inetmock
ARG USER_ID=10001
ENV CGO_ENABLED=0
# Prepare build stage - can be cached
WORKDIR /work
RUN apt-get update && \
apt-get install -y --no-install-recommends make gcc && \
adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${USER_ID}" \
"${USER}"
# Fetch dependencies
COPY Makefile go.mod go.sum ./
RUN go mod download
COPY ./ ./
# Build binary and plugins
RUN make CONTAINER=yes
# Runtime layer
FROM scratch
ENV INETMOCK_PLUGINS_DIRECTORY=/app/plugins/
WORKDIR /app
COPY --from=build /etc/passwd /etc/group /etc/
COPY --from=build --chown=$USER /work/inetmock ./
COPY --from=build --chown=$USER /work/*.so ./plugins/
USER $USER:$USER
ENTRYPOINT ["/app/inetmock"]