From aefa33ec863774482161be9c4d77e24b7f007bb5 Mon Sep 17 00:00:00 2001 From: infogulch Date: Sat, 6 Apr 2024 02:41:26 -0500 Subject: [PATCH] Fix dockerfile --- .github/workflows/release.sh | 6 +++--- Dockerfile | 7 ++++--- app/app.go | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.sh b/.github/workflows/release.sh index ab69a25..7799305 100755 --- a/.github/workflows/release.sh +++ b/.github/workflows/release.sh @@ -9,9 +9,9 @@ GITVER="$(git describe --exact-match --tags 2> /dev/null || git rev-parse --shor VERSION="$(go list -f '{{.Version}}' -m github.com/infogulch/xtemplate@$GITVER)" LDFLAGS="-X 'github.com/infogulch/xtemplate/app.version=$VERSION'" -GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-linux/xtemplate ./app/cmd -GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-darwin/xtemplate ./app/cmd -GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-windows/xtemplate.exe ./app/cmd +GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-linux/xtemplate ./cmd +GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-darwin/xtemplate ./cmd +GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -buildmode exe -o ./dist/xtemplate-amd64-windows/xtemplate.exe ./cmd docker build -t "xtemplate:$VERSION" --build-arg LDFLAGS="$LDFLAGS" . diff --git a/Dockerfile b/Dockerfile index 7444db2..2b20e2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,10 @@ RUN adduser \ --uid "${UID}" \ "${USER}" -WORKDIR /build/app +WORKDIR /build/cmd COPY go.mod go.sum /build/ COPY app/go.mod app/go.sum /build/app/ +COPY cmd/go.mod cmd/go.sum /build/cmd/ COPY providers/nats/go.mod providers/nats/go.sum /build/providers/nats/ RUN go mod download @@ -26,7 +27,7 @@ RUN CGO_ENABLED=1 \ GOFLAGS='-tags="sqlite_json"' \ GOOS=linux \ GOARCH=amd64 \ - go build -ldflags="${LDFLAGS}" -o /dist/xtemplate ./cmd + go build -ldflags="${LDFLAGS}" -o /dist/xtemplate . RUN ldd /dist/xtemplate | tr -s [:blank:] '\n' | grep ^/ | xargs -I % install -D % /dist/% RUN ln -s ld-musl-x86_64.so.1 /dist/lib/libc.musl-x86_64.so.1 @@ -45,4 +46,4 @@ EXPOSE 80 ENTRYPOINT ["/app/xtemplate"] -CMD ["-template-path", "/app/templates", "-watch-template", "false", "-log", "0", "-listen", ":80"] +CMD ["--template-dir", "./templates", "--watch-templates", "false", "--listen", ":80"] diff --git a/app/app.go b/app/app.go index 914119a..3b8a73c 100644 --- a/app/app.go +++ b/app/app.go @@ -11,8 +11,6 @@ import ( "github.com/alexflint/go-arg" "github.com/infogulch/watch" - - _ "github.com/infogulch/xtemplate/providers" ) type Args struct {