-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docker): support run and deploy to vercel in docker
- Loading branch information
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
**/*.png | ||
cache/ | ||
data/ | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM golang:1.21-alpine AS go-builder | ||
WORKDIR $GOPATH/src/github.com/ngshiheng/michelin-my-maps | ||
COPY . . | ||
RUN go build -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 | ||
|
||
COPY . . | ||
CMD ["./docker/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
main() { | ||
check | ||
run_mym | ||
publish_to_vercel | ||
} | ||
|
||
check() { | ||
echo "Checking..." | ||
if [ -z "$VERCEL_TOKEN" ]; then | ||
echo "Error: VERCEL_TOKEN is not set. Please set it before running this script." | ||
exit 1 | ||
fi | ||
|
||
if ! command -v vercel &>/dev/null; then | ||
echo "Error: vercel is not installed. Please install it before running this script." | ||
exit 1 | ||
fi | ||
|
||
if ! command -v datasette &>/dev/null; then | ||
echo "Error: datasette is not installed. Please install it before running this script." | ||
exit 1 | ||
fi | ||
} | ||
|
||
run_mym() { | ||
echo "Running mym..." | ||
mym | ||
if [ ! -f michelin.db ]; then | ||
echo "Error: michelin.db does not exist. Exiting..." | ||
exit 1 | ||
fi | ||
} | ||
|
||
publish_to_vercel() { | ||
echo "Publishing datasette to Vercel..." | ||
datasette publish vercel michelin.db --project=michelin-my-maps --install=datasette-cluster-map --token="$VERCEL_TOKEN" | ||
} | ||
|
||
main "$@" |