From 44de75380c5bce53828d4c1968a3bfb9c0bfecf5 Mon Sep 17 00:00:00 2001 From: Jerry Ng Date: Sat, 3 Feb 2024 20:46:16 +0800 Subject: [PATCH] chore(docker): fix go-sqlite3 requires cgo to work error --- docker/.dockerignore | 1 + docker/Dockerfile | 15 ++++++--------- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docker/.dockerignore b/docker/.dockerignore index d6fedee..594d41a 100644 --- a/docker/.dockerignore +++ b/docker/.dockerignore @@ -1,6 +1,7 @@ .git .github .vscode +*.db **/*.gif **/*.png cache/ diff --git a/docker/Dockerfile b/docker/Dockerfile index ff8fc6a..9ef2d6a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,20 +1,17 @@ FROM golang:1.21-alpine AS go-builder +ENV CGO_ENABLED=1 +RUN apk add --no-cache gcc musl-dev WORKDIR $GOPATH/src/github.com/ngshiheng/michelin-my-maps +COPY go.mod go.sum ./ +RUN go mod download COPY . . -RUN go build -o /bin/mym ./cmd/mym +RUN go build -ldflags='-s -w -extldflags "-static"' -o /bin/mym ./cmd/mym FROM datasetteproject/datasette RUN datasette install datasette-publish-vercel - COPY --from=go-builder /bin/mym /bin/mym - ARG VERCEL_TOKEN ENV VERCEL_TOKEN=${VERCEL_TOKEN} -RUN apt-get update -yq -RUN apt-get -yq install curl gnupg ca-certificates -RUN curl -L https://deb.nodesource.com/setup_18.x | bash -RUN apt-get install -yq nodejs -RUN npm i -g vercel - +RUN apt-get update -yq && apt-get -yq install curl gnupg ca-certificates && curl -L https://deb.nodesource.com/setup_18.x | bash && apt-get install -yq nodejs && npm i -g vercel COPY . . CMD ["./docker/docker-entrypoint.sh"] diff --git a/go.mod b/go.mod index 82310b9..96a0788 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/kennygrant/sanitize v1.2.4 // indirect - github.com/mattn/go-sqlite3 v1.14.17 // indirect + github.com/mattn/go-sqlite3 v1.14.19 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect github.com/temoto/robotstxt v1.1.2 // indirect diff --git a/go.sum b/go.sum index e76d7fc..5495ba6 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o= github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak= -github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= -github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= +github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/nyaruka/phonenumbers v1.3.1 h1:QcPRnL8hhZeSS6mB0p/Rlv7ma5ASmcgF33YLY0g0A8k= github.com/nyaruka/phonenumbers v1.3.1/go.mod h1:4jyKp/BFUokLbCHyoZag+T3S1KezFVoEKtgnbpzItC4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=