Postgres with liquibase in one docker image
FROM docker-proxy.tcsbank.ru/liquibase/liquibase:3.10.x AS LiquibaseFROM docker-proxy.tcsbank.ru/postgres:9.6.12 AS PostgresENV POSTGRES_DB bpmENV POSTGRES_USER priestENV POSTGRES_PASSWORD Bpm_123COPY --from=Liquibase /liquibase /liquibaseENV JAVA_HOME /usr/local/openjdk-11COPY --from=Liquibase $JAVA_HOME $JAVA_HOMEENV LIQUIBASE_CHANGELOG /liquibase/changelog/COPY /changelog $LIQUIBASE_CHANGELOGCOPY liquibase.sh /usr/local/bin/COPY main.sh /usr/local/bin/RUN chmod +x /usr/local/bin/liquibase.sh && \ chmod +x /usr/local/bin/main.sh && \ ln -s /usr/local/bin/main.sh / && \ ln -s /usr/local/bin/liquibase.sh /ENTRYPOINT ["main.sh"]
main.sh
#!/bin/bashbash liquibase.sh | awk '{print "liquiBase script: " $0}' &bash docker-entrypoint.sh postgres
liquibase.sh
#!/bin/bashfor COUNTER in {1..120}do sleep 1s echo "check db $COUNTER times" pg_isready if [ $? -eq 0 ] then break fidoneecho "try execute liquibase"bash liquibase/liquibase --url="jdbc:postgresql://localhost:5432/$POSTGRES_DB" --username=$POSTGRES_USER --password=$POSTGRES_PASSWORD --changeLogFile=/liquibase/changelog/changelog.xml update