Mopsican
Mopsican
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
thanks managed to do it, just needed to copy local packages and files as well
FROM golang:1.21.5 AS build

WORKDIR /blog

COPY go.mod go.sum ./
COPY ./shared/ ./shared/
COPY ./tem/ ./tem/
RUN go mod download

COPY ./blogPosts/ ./blogPosts/
COPY *.go ./
RUN go get ./shared/
RUN go get ./tem/
RUN go install
RUN ls *


RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main


FROM alpine:latest as final

WORKDIR /blog

COPY --from=build /blog/main ./
COPY --from=build /blog/blogPosts ./blogPosts/

ENTRYPOINT ["/blog/main"]
FROM golang:1.21.5 AS build

WORKDIR /blog

COPY go.mod go.sum ./
COPY ./shared/ ./shared/
COPY ./tem/ ./tem/
RUN go mod download

COPY ./blogPosts/ ./blogPosts/
COPY *.go ./
RUN go get ./shared/
RUN go get ./tem/
RUN go install
RUN ls *


RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main


FROM alpine:latest as final

WORKDIR /blog

COPY --from=build /blog/main ./
COPY --from=build /blog/blogPosts ./blogPosts/

ENTRYPOINT ["/blog/main"]
bit of a mess but it works
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
i mean get the build
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
maybe, i just need to get the exe, mod and sum + the last 2 lines
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
ARG GO_VERSION=1.21.5
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
WORKDIR /src
ARG TARGETARCH
FROM alpine:latest AS final
RUN mkdir -p home/index/
WORKDIR /home/
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,id=s/957287b0-89b6-4e31-9e44-84402206d00b-/root/cache/go-build,target=/root/.cache/go-build go build
RUN cd /home
COPY --from=build /bin/server /bin/
EXPOSE 8000
ENTRYPOINT [ "/bin/server" ]
ARG GO_VERSION=1.21.5
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
WORKDIR /src
ARG TARGETARCH
FROM alpine:latest AS final
RUN mkdir -p home/index/
WORKDIR /home/
COPY go.mod go.sum ./
RUN go mod download
RUN --mount=type=cache,id=s/957287b0-89b6-4e31-9e44-84402206d00b-/root/cache/go-build,target=/root/.cache/go-build go build
RUN cd /home
COPY --from=build /bin/server /bin/
EXPOSE 8000
ENTRYPOINT [ "/bin/server" ]
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
it doesn't seem to like bind mounts
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
#11 0.400 go: no modules specified (see 'go help mod download')
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
ok, it's just i need to use RUN --mount=type=cache,id=s/<service_id>/root/cache/go-build,target=/root/.cache/go-build \ apk --update add \ ca-certificates \ tzdata \ && \ update-ca-certificates and RUN --mount=type=cache,id=s/<service_id>/root/cache/go-build,target=/root/.cache/go-build \ --mount=type=bind,target=. \ CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server ./ as well
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
It's now throwing: Invalid cache mounts However, it still works locally. full example RUN --mount=type=cache,id=s/<service_id>/root/cache/go-build,target=/root/.cache/go-build \ --mount=type=bind,source=go.sum,target=go.sum \ --mount=type=bind,source=go.mod,target=go.mod \ go mod download -x do i need to change the targets?
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
sorry, i'm now getting Cache mount ID is not prefixed with cache key offending code RUN --mount=type=cache,id=<service_id>,target=/go/pkg/mod/ \
28 replies
RRailway
Created by Mopsican on 12/16/2023 in #✋|help
How to find Service ID - Docker Cache Mounts
thanks
28 replies