Clean up Dockerfile (#130)

This commit is contained in:
Roy Crihfield 2023-03-13 21:38:00 +08:00 committed by i-norden
parent 0595f3dc15
commit a91f44773c
2 changed files with 8 additions and 11 deletions

View File

@ -1,15 +1,12 @@
FROM golang:1.18-alpine as builder 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 # Get migration tool
WORKDIR /
# Build migration tool
WORKDIR /go/src/github.com/pressly
ARG GOOSE_VER="v3.6.1" ARG GOOSE_VER="v3.6.1"
RUN git clone --depth 1 --branch ${GOOSE_VER} https://github.com/pressly/goose.git ADD https://github.com/pressly/goose/releases/download/${GOOSE_VER}/goose_linux_x86_64 ./goose
WORKDIR /go/src/github.com/pressly/goose/cmd/goose RUN chmod +x ./goose
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_sqlite3' -o goose .
# app container # app container
FROM alpine 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/vulcanize/ipld-eth-db/scripts/startup_script.sh .
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose goose COPY --from=builder /goose goose
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/db/migrations migrations/vulcanizedb COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-db/db/migrations migrations
ENTRYPOINT ["/app/startup_script.sh"] ENTRYPOINT ["/app/startup_script.sh"]

View File

@ -8,7 +8,7 @@ VDB_PG_CONNECT=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME
# Run the DB migrations # Run the DB migrations
echo "Connecting with: $VDB_PG_CONNECT" echo "Connecting with: $VDB_PG_CONNECT"
echo "Running database migrations" 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 the db migrations ran without err
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then