Based on feedback from one of my previous blogs and updates to community project I made a few changes.
First Sqitch released an update that supported Perl 5.38 so I updated the application container to use that. I also had a discussion with the author and he suggested using default environment variables rather than building the sqitch configuration file over and over. So I updated that config file to look like:
[core]
engine = pg
top_dir = sql
target = main
[target "main"]
uri = db:pg:
and changed the Makefile
to map the incoming environment variables that define how to access the database to use the sqitch defaults for Postgresql:
update_db:
@echo "Running database migrations"
@env PGHOST=$(DB_HOST) PGPORT=$(DB_PORT) PGPASSWORD=$(POSTGRES_PASSWORD) \
PGUSER=$(POSTGRES_USER) PGDATABASE=$(POSTGRES_DB) sqitch deploy
Why not use the defaults in the docker compose file? Because I'm trying to think ahead and make sure my setup is future proof should I need to add more database models.
I was very pleased with this change since I always found the task of rebuilding the configuration file every time to have the properly environment variables to be an ugly hack.
I also cleaned up the Dockerfile
for the application service:
FROM perl:5.38.0
WORKDIR /app
# Core OS setup
RUN apt-get update
RUN apt-get install -y postgresql-client git vim
# Clean up
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
# Copy only the files needed for installing dependencies
COPY cpanfile* .
RUN cpanm --notest --installdeps .
# Copy the rest of the application source code
COPY . .
# Run the Catalyst application
CMD make server
I made similar changes to the Postgresql dockerfile. And I fixes a few minor bugs that popped up in testing. One was due to over enthusiastic copy pasta and I actually found a bug in the Valiant validations system which required a patch; that found it way to CPAN last night.
Thanks for the feedback everyone!
Top comments (0)