-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Layr-Labs/jac/container
chore: reduce build artifact to 117Mb
- Loading branch information
Showing
4 changed files
with
55 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM golang:1.22-bullseye | ||
|
||
ARG TARGETARCH | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt update && \ | ||
apt install -y -q --no-install-recommends \ | ||
build-essential gcc musl-dev linux-headers-${TARGETARCH} && \ | ||
apt clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN useradd --create-home -s /bin/bash gobuild | ||
RUN usermod -a -G sudo gobuild | ||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
ARG PROJECT=go-sidecar | ||
RUN mkdir -p /workspaces/${PROJECT} | ||
WORKDIR /workspaces/${PROJECT} | ||
COPY --chown=gobuild:gobuild . . | ||
|
||
# system and linux dependencies | ||
RUN make deps-linux | ||
RUN chown -R gobuild:gobuild /go | ||
|
||
# local dependencies | ||
ENV USER=gobuild | ||
ENV GOBIN=/go/bin | ||
ENV PATH=$PATH:${GOBIN} | ||
USER gobuild | ||
|
||
RUN git config --global --add safe.directory /workspaces/${PROJECT} | ||
|
||
RUN make yamlfmt | ||
RUN make fmtcheck | ||
RUN make vet | ||
RUN make lint | ||
RUN make test |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
FROM golang:1.22-bullseye AS build | ||
FROM golang:1.22-bullseye AS builder | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y make | ||
ARG TARGETARCH | ||
|
||
RUN useradd --create-home -s /bin/bash gobuild | ||
RUN usermod -a -G sudo gobuild | ||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt update && \ | ||
apt install -y -q --no-install-recommends \ | ||
build-essential gcc musl-dev linux-headers-${TARGETARCH} && \ | ||
apt clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ARG PROJECT=go-sidecar | ||
RUN mkdir -p /workspaces/${PROJECT} | ||
WORKDIR /workspaces/${PROJECT} | ||
COPY --chown=gobuild:gobuild . . | ||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
# system and linux dependencies | ||
RUN make deps-linux | ||
RUN chown -R gobuild:gobuild /go | ||
|
||
# local dependencies | ||
ENV USER=gobuild | ||
ENV GOBIN=/go/bin | ||
ENV PATH=$PATH:${GOBIN} | ||
USER gobuild | ||
RUN make build | ||
|
||
FROM debian:stable-slim | ||
|
||
RUN git config --global --add safe.directory /workspaces/${PROJECT} | ||
COPY --from=builder /build/bin/cmd/sidecar /usr/local/bin/sidecar | ||
|
||
RUN make yamlfmt | ||
RUN make fmtcheck | ||
RUN make vet | ||
RUN make lint | ||
RUN make test | ||
ENTRYPOINT ["/usr/local/bin/sidecar"] |
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