Split Dockerfile into build & run images

This commit is contained in:
Michal Kunc 2022-02-13 16:38:58 +01:00
parent 96db44ce34
commit 7e24464387

View File

@ -1,17 +1,19 @@
FROM alpine:3.15.0
FROM alpine:3.15.0 AS build
VOLUME ["/data"]
COPY . /oko-server/git
RUN apk add --no-cache go && \
cd /oko-server/git && \
go build && \
cp /oko-server/git/oko-server /oko-server/ && \
cd /oko-server && \
rm -rf /oko-server/git && \
apk del go && \
rm -rf /root/go && \
echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \
go build
FROM alpine:3.15.0
WORKDIR /oko-server
VOLUME [ "/data" ]
RUN echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \
chmod +x /oko-server/entrypoint.sh
COPY --from=build /oko-server/git/oko-server/ /oko-server/
ENTRYPOINT ["/oko-server/entrypoint.sh"]