mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Added cmake dep to dockerfile and added script for db:schema:load that runs only if the schema is different than the latest migration
This commit is contained in:
@@ -14,7 +14,7 @@ FROM base AS development-base
|
||||
RUN apk add --no-cache --virtual .build-deps \
|
||||
build-base postgresql-dev git nodejs yarn && \
|
||||
apk add --no-cache --virtual .dev-utils \
|
||||
bash curl less vim chromium-chromedriver zlib-dev openssl-dev \
|
||||
bash curl less vim chromium-chromedriver zlib-dev openssl-dev cmake\
|
||||
readline-dev yaml-dev sqlite-dev libxml2-dev libxslt-dev libffi-dev vips-dev && \
|
||||
curl -o /usr/local/bin/wait-for-it https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && \
|
||||
chmod +x /usr/local/bin/wait-for-it
|
||||
|
||||
@@ -25,7 +25,8 @@ RUN apt-get update && apt-get install -y \
|
||||
libjemalloc-dev \
|
||||
libssl-dev \
|
||||
ca-certificates \
|
||||
gnupg
|
||||
gnupg \
|
||||
cmake
|
||||
|
||||
# Setup ENV variables
|
||||
ENV PATH /usr/local/src/rbenv/shims:/usr/local/src/rbenv/bin:/usr/local/src/nodenv/shims:/usr/local/src/nodenv/bin:$PATH
|
||||
|
||||
@@ -38,6 +38,8 @@ services:
|
||||
bash -c "rm -f tmp/pids/server.pid &&
|
||||
(bundle check || bundle install) &&
|
||||
bundle exec rake db:create &&
|
||||
chmod +x ./script/load_schema.sh &&
|
||||
./script/load_schema.sh &&
|
||||
yarn install &&
|
||||
bundle exec foreman start -f Procfile.docker"
|
||||
volumes:
|
||||
|
||||
15
script/load_schema.sh
Executable file
15
script/load_schema.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🔍 Checking if schema is missing or outdated..."
|
||||
|
||||
# Get the current DB version
|
||||
DB_VERSION=$(bundle exec rails db:version | grep 'Current version' | awk '{print $NF}')
|
||||
FILE_VERSION=$(grep 'version:' db/schema.rb | awk '{print $2}')
|
||||
|
||||
if [ -z "$DB_VERSION" ] || [ "$DB_VERSION" != "$FILE_VERSION" ]; then
|
||||
echo "🧾 Schema mismatch detected (DB=$DB_VERSION, File=$FILE_VERSION). Running db:schema:load..."
|
||||
bundle exec rails db:schema:load
|
||||
else
|
||||
echo "✅ Schema is up to date (version $DB_VERSION)."
|
||||
fi
|
||||
Reference in New Issue
Block a user