update Dockerfile to pass GOFLAGS

This commit is contained in:
Jeffrey Morgan 2023-10-03 07:05:09 -07:00
parent 367cb68dc1
commit dc87e9c9ae
2 changed files with 4 additions and 4 deletions

View file

@ -1,7 +1,6 @@
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
ARG TARGETARCH ARG TARGETARCH
ARG VERSION=0.0.0
ARG GOFLAGS="'-ldflags=-w -s'" ARG GOFLAGS="'-ldflags=-w -s'"
WORKDIR /go/src/github.com/jmorganca/ollama WORKDIR /go/src/github.com/jmorganca/ollama
@ -11,6 +10,7 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gz
COPY . . COPY . .
ENV GOARCH=$TARGETARCH ENV GOARCH=$TARGETARCH
ENV GOFLAGS=$GOFLAGS
RUN /usr/local/go/bin/go generate ./... \ RUN /usr/local/go/bin/go generate ./... \
&& /usr/local/go/bin/go build . && /usr/local/go/bin/go build .

View file

@ -14,6 +14,7 @@ RUN yum install -y git cmake
FROM base-${TARGETARCH} FROM base-${TARGETARCH}
ARG TARGETARCH ARG TARGETARCH
ARG GOFLAGS="'-ldflags -w -s'"
# install go # install go
ADD https://dl.google.com/go/go1.21.1.linux-$TARGETARCH.tar.gz /tmp/go1.21.1.tar.gz ADD https://dl.google.com/go/go1.21.1.linux-$TARGETARCH.tar.gz /tmp/go1.21.1.tar.gz
@ -22,11 +23,10 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gz
# build the final binary # build the final binary
WORKDIR /go/src/github.com/jmorganca/ollama WORKDIR /go/src/github.com/jmorganca/ollama
COPY . . COPY . .
ENV GOOS=linux ENV GOOS=linux
ENV GOARCH=$TARGETARCH ENV GOARCH=$TARGETARCH
ENV GOFLAGS=$GOFLAGS
ARG VERSION=0.0.0
ARG GOFLAGS="'-ldflags -w -s'"
RUN /usr/local/go/bin/go generate ./... && \ RUN /usr/local/go/bin/go generate ./... && \
/usr/local/go/bin/go build . /usr/local/go/bin/go build .