-
Hello! I'm trying to dockerize my golang web project, here is source code, and after success build container, there is an error:
My # syntax=docker/dockerfile:1
ARG GO_VERSION=1.23.0
ARG ALPINE_VERSION=3.20.2
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
WORKDIR /src
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,target=. \
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server ./cmd/server
FROM alpine:${ALPINE_VERSION} AS final
RUN --mount=type=cache,target=/var/cache/apk \
apk --update add \
ca-certificates \
tzdata \
&& \
update-ca-certificates
ADD 'https://github.com/apple/pkl/releases/download/0.26.3/pkl-alpine-linux-amd64' /bin/pkl
RUN chmod +x /bin/pkl
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
tikhon
USER tikhon
COPY --from=build /bin/server /bin/
COPY pkl pkl
EXPOSE 9990
ENTRYPOINT [ "/bin/server" ]
@go.Package { name = "github.com/TikhonP/medsenger-freestylelibre-bot/config" }
module config
import "package://pkg.pkl-lang.org/pkl-go/[email protected]#/go.pkl"
class Server {
host: String
port: UInt16
medsengerAgentKey: String
debug: Boolean
}
class Database {
user: String
password: String
dbname: String
host: String
}
server: Server
db: Database
fetchSleepDuration: Duration
sentryDSN: String How to properly run pkl in a docker container? |
Beta Was this translation helpful? Give feedback.
Answered by
HT154
Aug 25, 2024
Replies: 1 comment 2 replies
-
The issue is that the user your application is running as has a home directory that doesn't exist. By default, Pkl will cache package access inside the home directory. You have two options here:
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tikhonp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is that the user your application is running as has a home directory that doesn't exist. By default, Pkl will cache package access inside the home directory. You have two options here: