Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

421
Views
Postgres with liquibase in one docker image

I want to create dataBase for autotest in kubernetes. I want to create an image(postg-my-app-v1) from postgres image, add changelog files, and liquibase image. When I deploy this image with helm i just want to specify containers - postg-my-app-v1 and it should startup pod with database and create tables with liquibase changelog.

Now i create Dockerfile as below

FROM postgres
ADD /changelog /liquibase/changelog

I don't understand how to add liquibase to this image? Or i must use docker compose? or helm lifecycle postStart for liquibase?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

FROM docker-proxy.tcsbank.ru/liquibase/liquibase:3.10.x AS Liquibase

FROM docker-proxy.tcsbank.ru/postgres:9.6.12 AS Postgres
ENV POSTGRES_DB bpm
ENV POSTGRES_USER priest
ENV POSTGRES_PASSWORD Bpm_123


COPY --from=Liquibase /liquibase /liquibase

ENV JAVA_HOME /usr/local/openjdk-11
COPY --from=Liquibase $JAVA_HOME $JAVA_HOME


ENV LIQUIBASE_CHANGELOG /liquibase/changelog/
COPY /changelog $LIQUIBASE_CHANGELOG


COPY 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/bash

bash liquibase.sh | awk '{print "liquiBase script: " $0}' &

bash docker-entrypoint.sh postgres

liquibase.sh

#!/bin/bash

for COUNTER in {1..120}
do
   sleep 1s
   echo "check db $COUNTER times"
   pg_isready
   if [ $? -eq 0 ]
   then
     break
   fi
done

echo "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
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!