Nuke OpenRC from docker image, update readme's
This commit is contained in:
parent
0bf8bd4183
commit
9b986c4c14
@ -14,16 +14,11 @@ RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflag
|
|||||||
|
|
||||||
# Second stage
|
# Second stage
|
||||||
FROM alpine
|
FROM alpine
|
||||||
RUN apk --no-cache --update add openrc
|
|
||||||
RUN mkdir -p /run/openrc/ && touch /run/openrc/softlevel
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/vulcanizedb /app/vulcanizedb
|
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/vulcanizedb /app/vulcanizedb
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/environments/staging.toml /app/environments/
|
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/environments/staging.toml /app/environments/
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/dockerfiles/lightSync-service /etc/init.d/lightSync
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/dockerfiles/continuousLogSync-service /etc/init.d/continuousLogSync
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/dockerfiles/startup_script.sh /app/
|
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/dockerfiles/startup_script.sh /app/
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/db/migrations/* /app/
|
COPY --from=builder /go/src/github.com/vulcanize/vulcanizedb/db/migrations/* /app/
|
||||||
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose /app/goose
|
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose /app/goose
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN rc-status
|
CMD ["./startup_script.sh"]
|
||||||
CMD ["./goose"]
|
|
||||||
|
@ -19,14 +19,14 @@ e`
|
|||||||
* `CONTRACT_ABI_[CONTRACT NAME]="ABI STRING"`
|
* `CONTRACT_ABI_[CONTRACT NAME]="ABI STRING"`
|
||||||
* `CONTRACT_DEPLOYMENT-BLOCK_[CONTRACT NAME]=0` (doesn't really matter on a short chain, just avoids long unnecessary searching)
|
* `CONTRACT_DEPLOYMENT-BLOCK_[CONTRACT NAME]=0` (doesn't really matter on a short chain, just avoids long unnecessary searching)
|
||||||
6. Start the `lightSync` and `continuousLogSync` services:
|
6. Start the `lightSync` and `continuousLogSync` services:
|
||||||
* `rc-service lightSync start`
|
* `./vulcanizedb lightSync --config environments/staging.toml`
|
||||||
* `rc-service continuousLogSync start`
|
* `./vulcanizedb continuousLogSync --config environments/staging.toml`
|
||||||
|
|
||||||
### Automated
|
### Automated
|
||||||
The steps above have been rolled into a script: `/app/startup_script.sh`, which just assumes the DB env variables have been set, and defaults the rest to Kovan according to `environments/staging.toml`. This can be called with something like:
|
The steps above have been rolled into a script: `/app/startup_script.sh`, which just assumes the DB env variables have been set, and defaults the rest to Kovan according to `environments/staging.toml`. This can be called with something like:
|
||||||
|
|
||||||
`docker run -d -e DATABASE_NAME=vulcanize_public -e DATABASE_HOSTNAME=localhost -e DATABASE_PORT=5432 -e DATABASE_USER=vulcanize -e DATABASE_PASSWORD=vulcanize [container name] ./startup_script.sh`
|
`docker run -d -e DATABASE_NAME=vulcanize_public -e DATABASE_HOSTNAME=localhost -e DATABASE_PORT=5432 -e DATABASE_USER=vulcanize -e DATABASE_PASSWORD=vulcanize m0ar/images:vDB`
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
When running, vDB services log to `/vulcanizedb.log`.
|
When running, vDB services log to `/app/vulcanizedb.log`.
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/sbin/openrc-run
|
|
||||||
command=/app/vulcanizedb
|
|
||||||
command_args="continuousLogSync --config /app/environments/staging.toml &"
|
|
||||||
pidfile=
|
|
||||||
name="continuousLogSync"
|
|
||||||
description="runs vDB in continuousLogSync mode using staging.toml"
|
|
@ -1,6 +0,0 @@
|
|||||||
#!/sbin/openrc-run
|
|
||||||
command=/app/vulcanizedb
|
|
||||||
command_args="lightSync --config /app/environments/staging.toml &"
|
|
||||||
pidfile=
|
|
||||||
name="lightSync"
|
|
||||||
description="runs vDB in lightSync mode using staging.toml"
|
|
@ -21,9 +21,9 @@ set +e
|
|||||||
./goose postgres "$CONNECT_STRING" up
|
./goose postgres "$CONNECT_STRING" up
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
# Fire up the services
|
# Fire up the services
|
||||||
rc-service lightSync start
|
./vulcanizedb lightSync --config environments/staging.toml &
|
||||||
rc-service continuousLogSync start
|
./vulcanizedb continuousLogSync --config environments/staging.toml &
|
||||||
else
|
else
|
||||||
echo "Could not run migrations. Are the database details correct?"
|
echo "Could not run migrations. Are the database details correct?"
|
||||||
fi
|
fi
|
||||||
|
wait
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
[database]
|
[database]
|
||||||
name = "vulcanize_public"
|
|
||||||
hostname = "localhost"
|
|
||||||
user = "vulcanize"
|
|
||||||
password = "vulcanize"
|
|
||||||
port = 5432
|
port = 5432
|
||||||
|
|
||||||
[client]
|
[client]
|
||||||
|
@ -18,6 +18,7 @@ package postgres
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
_ "github.com/lib/pq" //postgres driver
|
_ "github.com/lib/pq" //postgres driver
|
||||||
@ -40,6 +41,7 @@ var (
|
|||||||
|
|
||||||
func NewDB(databaseConfig config.Database, node core.Node) (*DB, error) {
|
func NewDB(databaseConfig config.Database, node core.Node) (*DB, error) {
|
||||||
connectString := config.DbConnectionString(databaseConfig)
|
connectString := config.DbConnectionString(databaseConfig)
|
||||||
|
logrus.Info("Using connection string: ", connectString)
|
||||||
db, err := sqlx.Connect("postgres", connectString)
|
db, err := sqlx.Connect("postgres", connectString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &DB{}, ErrDBConnectionFailed
|
return &DB{}, ErrDBConnectionFailed
|
||||||
|
@ -6,23 +6,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var initialized = false
|
|
||||||
|
|
||||||
func initConfig() {
|
|
||||||
if initialized {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err == nil {
|
|
||||||
fmt.Printf("Using config file: %s\n\n", viper.ConfigFileUsed())
|
|
||||||
} else {
|
|
||||||
panic(fmt.Sprintf("Could not find environment file: %v", err))
|
|
||||||
}
|
|
||||||
initialized = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func getEnvironmentString(key string) string {
|
func getEnvironmentString(key string) string {
|
||||||
initConfig()
|
|
||||||
value := viper.GetString(key)
|
value := viper.GetString(key)
|
||||||
if value == "" {
|
if value == "" {
|
||||||
panic(fmt.Sprintf("No environment configuration variable set for key: \"%v\"", key))
|
panic(fmt.Sprintf("No environment configuration variable set for key: \"%v\"", key))
|
||||||
@ -32,7 +16,6 @@ func getEnvironmentString(key string) string {
|
|||||||
|
|
||||||
// Returns an int from the environment, defaulting to 0 if it does not exist
|
// Returns an int from the environment, defaulting to 0 if it does not exist
|
||||||
func getEnvironmentInt64(key string) int64 {
|
func getEnvironmentInt64(key string) int64 {
|
||||||
initConfig()
|
|
||||||
value := viper.GetInt64(key)
|
value := viper.GetInt64(key)
|
||||||
if value == -1 {
|
if value == -1 {
|
||||||
return 0
|
return 0
|
||||||
|
@ -6,4 +6,4 @@ COPY . /app
|
|||||||
run yarn install
|
run yarn install
|
||||||
RUN ["./node_modules/typescript/bin/tsc"]
|
RUN ["./node_modules/typescript/bin/tsc"]
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["node", "/app/build/dist/src/index.js"]
|
CMD ["node", "/app/build/dist/index.js"]
|
||||||
|
@ -10,7 +10,7 @@ Build the docker image in this directory. Start the `GraphiQL` frontend by:
|
|||||||
`DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD` (and optionally
|
`DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD` (and optionally
|
||||||
`DATABASE_PORT` if running on non-standard port).
|
`DATABASE_PORT` if running on non-standard port).
|
||||||
* The specified user needs to be `superuser` on the vulcanizeDB database
|
* The specified user needs to be `superuser` on the vulcanizeDB database
|
||||||
* Run the container (ex. `docker run -e DATABASE_HOST=localhost -e DATABASE_NAME=vulcanize_public -e DATABASE_USER=vulcanize -e DATABASE_PASSWORD=vulcanize -d postgraphile:latest`)
|
* Run the container (ex. `docker run -e DATABASE_HOST=localhost -e DATABASE_NAME=vulcanize_public -e DATABASE_USER=vulcanize -e DATABASE_PASSWORD=vulcanize -d m0ar/images:postgraphile-alpine`)
|
||||||
* GraphiQL is available at `:3000/graphiql`
|
* GraphiQL is available at `:3000/graphiql`
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user