diff --git a/web3signer.yml b/web3signer.yml index 5cf24fc2..463f544a 100644 --- a/web3signer.yml +++ b/web3signer.yml @@ -7,6 +7,28 @@ x-logging: &logging tag: '{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}' services: + w3s-init: + restart: "no" + build: + context: ./web3signer + args: + - DOCKER_TAG=${W3S_DOCKER_TAG:-latest} + - DOCKER_REPO=${W3S_DOCKER_REPO:-consensys/web3signer} + dockerfile: Dockerfile.init + image: w3s-init:local + pull_policy: never + depends_on: + postgres: + condition: service_healthy + <<: *logging + entrypoint: + - /flyway/flyway + - migrate + - -url=jdbc:postgresql://${PG_ALIAS}/web3signer + - -user=postgres + - -password=postgres + - -locations=filesystem:/tmp/web3signer + web3signer: restart: "unless-stopped" build: @@ -31,8 +53,8 @@ services: # This allows multiple Eth Docker stacks all connected to the same bridge network - ${W3S_ALIAS:-${NETWORK}-web3signer} depends_on: - postgres: - condition: service_healthy + w3s-init: + condition: service_completed_successfully <<: *logging entrypoint: - docker-entrypoint.sh diff --git a/web3signer/Dockerfile.binary b/web3signer/Dockerfile.binary index 62abdd44..69863be5 100644 --- a/web3signer/Dockerfile.binary +++ b/web3signer/Dockerfile.binary @@ -2,8 +2,6 @@ ARG DOCKER_TAG=latest ARG DOCKER_REPO=consensys/web3signer -FROM flyway/flyway:latest AS flyway - FROM ${DOCKER_REPO}:${DOCKER_TAG} ARG USER=web3signer @@ -27,10 +25,6 @@ COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/ # Belt and suspenders RUN chmod -R 755 /usr/local/bin/* -# Flyway for initial migrations - -COPY --from=flyway --chown=${USER}:${USER} /flyway /flyway - USER ${USER} ENTRYPOINT ["/opt/web3signer/bin/web3signer"] diff --git a/web3signer/Dockerfile.init b/web3signer/Dockerfile.init new file mode 100644 index 00000000..7d42c85b --- /dev/null +++ b/web3signer/Dockerfile.init @@ -0,0 +1,9 @@ +# hadolint global ignore=DL3007,DL3008,DL3059 +ARG DOCKER_TAG=latest +ARG DOCKER_REPO=consensys/web3signer + +FROM ${DOCKER_REPO}:${DOCKER_TAG} AS web3signer + +FROM flyway/flyway:latest + +COPY --from=web3signer /opt/web3signer/migrations/postgresql /tmp/web3signer diff --git a/web3signer/docker-entrypoint.sh b/web3signer/docker-entrypoint.sh index 58cbe644..9a1327be 100755 --- a/web3signer/docker-entrypoint.sh +++ b/web3signer/docker-entrypoint.sh @@ -36,8 +36,6 @@ if [[ -f /var/lib/web3signer/.migration_fatal_error ]]; then exit 1 fi -/flyway/flyway migrate -url="jdbc:postgresql://${PG_ALIAS}/web3signer" -user=postgres -password=postgres -locations=filesystem:/opt/web3signer/migrations/postgresql - # Word splitting is desired for the command line parameters # shellcheck disable=SC2086 exec "$@" ${__network}