generated from dappnode/DAppNodePackage-web3signer-prater
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from dappnode/dappnodedev/improve-build
Improve package build
- Loading branch information
Showing
5 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
ARG UPSTREAM_VERSION | ||
|
||
############## | ||
# MIGRATIONS # | ||
############## | ||
FROM debian:bullseye-slim as postgres-migrations | ||
FROM alpine:3.15.10 as postgres-migrations | ||
ARG UPSTREAM_VERSION | ||
WORKDIR /usr/src/app | ||
RUN apt update && apt install -y wget | ||
# Get migrations from consensys web3signer repo | ||
# path is /usr/src/app/web3signer-21.10.0/slashing-protection/src/main/resources/migrations/postgresql | ||
|
||
# Install wget and other dependencies, if necessary | ||
RUN apk --no-cache add wget | ||
|
||
# Get migrations from ConsenSys web3signer repository | ||
RUN wget -q https://github.com/ConsenSys/web3signer/archive/refs/tags/${UPSTREAM_VERSION}.tar.gz && \ | ||
tar -xvf ${UPSTREAM_VERSION}.tar.gz | ||
tar -xvf ${UPSTREAM_VERSION}.tar.gz && \ | ||
rm ${UPSTREAM_VERSION}.tar.gz | ||
|
||
########## | ||
# FLYWAY # | ||
########## | ||
FROM flyway/flyway:9.16.1-alpine | ||
ARG UPSTREAM_VERSION | ||
RUN apk update && apk add postgresql-client | ||
|
||
RUN apk update && apk --no-cache add postgresql-client | ||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh && rm /flyway/sql/put-your-sql-migrations-here.txt | ||
RUN chmod +x /usr/local/bin/entrypoint.sh && rm -rf /flyway/sql/* | ||
COPY --from=postgres-migrations /usr/src/app/web3signer-${UPSTREAM_VERSION}/slashing-protection/src/main/resources/migrations/postgresql/* /flyway/sql/ | ||
ENTRYPOINT ["entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
ARG UPSTREAM_VERSION | ||
|
||
########## | ||
# FLYWAY # | ||
########## | ||
#FROM flyway/flyway:8.0.5-alpine as binary-flyway | ||
#COPY --from=binary-flyway /flyway/flyway /usr/local/bin/flyway | ||
|
||
############## | ||
# MIGRATIONS # | ||
############## | ||
FROM debian:bullseye-slim as postgres-migrations | ||
FROM alpine:3.15.10 as postgres-migrations | ||
ARG UPSTREAM_VERSION | ||
WORKDIR /usr/src/app | ||
|
||
RUN apt update && apt install -y wget | ||
# Get migrations from consensys web3signer repo | ||
# path is /usr/src/app/web3signer-21.10.0/slashing-protection/src/main/resources/migrations/postgresql | ||
# Install wget and other dependencies, if necessary | ||
RUN apk --no-cache add wget | ||
|
||
# Get migrations from ConsenSys web3signer repository | ||
RUN wget -q https://github.com/ConsenSys/web3signer/archive/refs/tags/${UPSTREAM_VERSION}.tar.gz && \ | ||
tar -xvf ${UPSTREAM_VERSION}.tar.gz | ||
tar -xvf ${UPSTREAM_VERSION}.tar.gz && \ | ||
rm ${UPSTREAM_VERSION}.tar.gz | ||
|
||
############ | ||
# POSTGRES # | ||
############ | ||
FROM postgres:14.1-bullseye | ||
FROM postgres:14.1-alpine3.15 | ||
|
||
ARG UPSTREAM_VERSION | ||
ENV POSTGRES_PASSWORD=gnosis | ||
ENV PGPASSWORD=gnosis | ||
ENV POSTGRES_USER=postgres | ||
ENV POSTGRES_DB=web3signer-gnosis | ||
RUN apt update && apt install -y rename | ||
|
||
COPY --from=postgres-migrations /usr/src/app/web3signer-${UPSTREAM_VERSION}/slashing-protection/src/main/resources/migrations/postgresql/* /docker-entrypoint-initdb.d/ | ||
# Rename scripts to be executed in alfabetical order | ||
RUN rename 's/(\d+)(?=.*\.)/sprintf("%03d",$1)/eg' /docker-entrypoint-initdb.d/* | ||
ENV POSTGRES_PASSWORD=gnosis \ | ||
PGPASSWORD=gnosis \ | ||
POSTGRES_USER=postgres \ | ||
POSTGRES_DB=web3signer-gnosis \ | ||
INITDB_DIR=/docker-entrypoint-initdb.d/ | ||
|
||
COPY rename_files.sh /usr/local/bin/rename_files.sh | ||
|
||
COPY --from=postgres-migrations /usr/src/app/web3signer-${UPSTREAM_VERSION}/slashing-protection/src/main/resources/migrations/postgresql/* ${INITDB_DIR} | ||
|
||
RUN /usr/local/bin/rename_files.sh | ||
|
||
USER postgres | ||
|
||
CMD ["postgres"] | ||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
# Loop over each file in the /docker-entrypoint-initdb.d directory | ||
for file in ${INITDB_DIR}*; do | ||
# Extract the base name and directory of the file | ||
dir=$(dirname "$file") | ||
base=$(basename "$file") | ||
|
||
# Use sed to modify the file name | ||
# This will pad the first number in the file name with zeros to make it three digits long | ||
new_base=$(echo "$base" | sed -r 's/([0-9]+)/000\1/g; s/0*([0-9]{3})/\1/g') | ||
|
||
# Move (rename) the file to its new name | ||
mv "$dir/$base" "$dir/$new_base" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters