forked from cerc-io/ipld-eth-server
rename blocks table to eth_blocks so that we don't clash with the ipfs blocks table; dockerfile and startup_script for the seed node
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
FROM golang:alpine as builder
|
||||
|
||||
RUN apk --update --no-cache add make git g++
|
||||
# DEBUG
|
||||
RUN apk add busybox-extras
|
||||
|
||||
# Build statically linked vDB binary (wonky path because of Dep)
|
||||
WORKDIR /go/src/github.com/vulcanize/vulcanizedb
|
||||
ADD . .
|
||||
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' .
|
||||
|
||||
# Build statically linked IPFS binary (statically linked and wonky path because we need to use custom fork)
|
||||
WORKDIR /go/src/github.com/ipfs/go-ipfs
|
||||
ADD . .
|
||||
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' .
|
||||
|
||||
# Build statically linked Geth binary (statically linked and wonky path because we need to use custom fork)
|
||||
WORKDIR /go/src/github.com/ethereum/go-ethereum
|
||||
ADD . .
|
||||
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' .
|
||||
|
||||
# Build migration tool
|
||||
RUN go get -u -d github.com/pressly/goose/cmd/goose
|
||||
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_mysql no_sqlite' -o goose
|
||||
|
||||
WORKDIR /go/src/github.com/vulcanize/vulcanizedb
|
||||
|
||||
# app container
|
||||
FROM alpine
|
||||
WORKDIR /app
|
||||
|
||||
ARG USER
|
||||
ARG config_file=environments/example.toml
|
||||
ARG vdb_command=syncPublishScreenAndServe
|
||||
ARG vdb_pg_connect="postgres://$USER@/vulcanize_public?sslmode=disable"
|
||||
ARG vdb_dbname="vulcanize_public"
|
||||
|
||||
# setup environment
|
||||
ENV VDB_COMMAND="$vdb_command"
|
||||
ENV VDB_PG_CONNECT="$vdb_pg_connect"
|
||||
|
||||
RUN adduser -Du 5000 $USER
|
||||
USER $USER
|
||||
|
||||
# chown first so dir is writable
|
||||
# note: using $USER is merged, but not in the stable release yet
|
||||
COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/vulcanizedb/$config_file config.toml
|
||||
COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/vulcanizedb/dockerfiles/seed_node/startup_script.sh .
|
||||
|
||||
# keep binaries immutable
|
||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/vulcanizedb vulcanizedb
|
||||
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose goose
|
||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/db/migrations migrations/vulcanizedb
|
||||
COPY --from=builder /go/src/github.com/ipfs/go-ipfs ipfs
|
||||
COPY --from=builder /go/src/github.com/ethereum/go-ethereum geth
|
||||
|
||||
# DEBUG
|
||||
COPY --from=builder /usr/bin/telnet /bin/telnet
|
||||
|
||||
CMD ["./startup_script.sh"]
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs the migrations and starts the syncPublishScreenAndServe service
|
||||
|
||||
# Exit if the variable tests fail
|
||||
set -e
|
||||
|
||||
# Check the database variables are set
|
||||
test $DATABASE_NAME
|
||||
test $DATABASE_HOSTNAME
|
||||
test $DATABASE_PORT
|
||||
test $DATABASE_USER
|
||||
test $DATABASE_PASSWORD
|
||||
|
||||
# Export our database variables so that the IPFS Postgres plugin can use them
|
||||
export IPFS_PGHOST=$DATABASE_HOSTNAME
|
||||
export IPFS_PGUSER=$DATABASE_USER
|
||||
export IPFS_PGDATABASE=$DATABASE_NAME
|
||||
export IPFS_PGPORT=$DATABASE_PORT
|
||||
export IPFS_PGPASSWORD=$DATABASE_PASSWORD
|
||||
|
||||
# Construct the connection string for postgres
|
||||
CONNECT_STRING=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME:$DATABASE_PORT/$DATABASE_NAME?sslmode=disable
|
||||
echo "Connecting with: $CONNECT_STRING"
|
||||
|
||||
set +e
|
||||
|
||||
# Run the DB migrations
|
||||
./goose postgres "$CONNECT_STRING" up
|
||||
if [ $? -eq 0 ]; then
|
||||
# Fire up the services
|
||||
ipfs ipfs init --profile=postgresds
|
||||
geth --statediff --statediff.streamblock --ws --syncmode=full
|
||||
./vulcanizedb syncPublishScreenAndServe --config environments/seedNodeStaging.toml &
|
||||
else
|
||||
echo "Could not run migrations. Are the database details correct?"
|
||||
fi
|
||||
wait
|
||||
Reference in New Issue
Block a user