From a91f44773cc2e8ca53e93186ff15e7593d6e1008 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Mon, 13 Mar 2023 21:38:00 +0800 Subject: [PATCH] Clean up Dockerfile (#130) --- Dockerfile | 17 +++++++---------- scripts/startup_script.sh | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf65fe3..b0a015d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,12 @@ FROM golang:1.18-alpine as builder -RUN apk --update --no-cache add make git g++ linux-headers +ADD . /go/src/github.com/cerc-io/ipld-eth-db -ADD . /go/src/github.com/vulcanize/ipld-eth-db - -# Build migration tool -WORKDIR /go/src/github.com/pressly +# Get migration tool +WORKDIR / ARG GOOSE_VER="v3.6.1" -RUN git clone --depth 1 --branch ${GOOSE_VER} https://github.com/pressly/goose.git -WORKDIR /go/src/github.com/pressly/goose/cmd/goose -RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_sqlite3' -o goose . +ADD https://github.com/pressly/goose/releases/download/${GOOSE_VER}/goose_linux_x86_64 ./goose +RUN chmod +x ./goose # app container FROM alpine @@ -18,7 +15,7 @@ WORKDIR /app COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/scripts/startup_script.sh . -COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose goose -COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/db/migrations migrations/vulcanizedb +COPY --from=builder /goose goose +COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-db/db/migrations migrations ENTRYPOINT ["/app/startup_script.sh"] diff --git a/scripts/startup_script.sh b/scripts/startup_script.sh index 404f6e3..0535f5e 100755 --- a/scripts/startup_script.sh +++ b/scripts/startup_script.sh @@ -8,7 +8,7 @@ VDB_PG_CONNECT=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME # Run the DB migrations echo "Connecting with: $VDB_PG_CONNECT" echo "Running database migrations" -./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up +./goose -dir migrations postgres "$VDB_PG_CONNECT" up # If the db migrations ran without err if [[ $? -eq 0 ]]; then