Created
April 22, 2022 21:31
-
-
Save 1k-off/cb1da229554b8dcbeb2e23d25a3b1d6c to your computer and use it in GitHub Desktop.
Build golang app with embedded python to docker scratch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1-alpine as build | |
WORKDIR /app | |
RUN apk update && apk add --no-cache ca-certificates | |
COPY go.mod go.sum ./ | |
RUN go mod download | |
COPY . . | |
WORKDIR /app/cmd/tkp | |
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/tkp | |
FROM python:3.10 as integration | |
RUN apt-get update && \ | |
apt-get install -y build-essential patchelf | |
RUN pip3 install pyinstaller staticx | |
COPY thirdparty/tkp-integ /app | |
WORKDIR /app | |
RUN pip3 install -r requirements.txt | |
RUN pyinstaller -F tkp-integ.py | |
WORKDIR /app/dist | |
RUN staticx tkp-integ tkp-integration | |
FROM scratch | |
WORKDIR /app | |
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | |
COPY --from=integration --chown=65535:65535 /app/dist/tkp-integration /app/tkp-integ | |
COPY --from=build --chown=65535:65535 /app/tkp /app/tkp | |
USER 65535 | |
EXPOSE 8080 | |
CMD ["/app/tkp"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment