diff --git a/Dockerfile.dev b/Dockerfile.dev index e17f196..d590127 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,16 +1,27 @@ -FROM ruby:3.4 +FROM ruby:3.4-slim -RUN gem install bundler +# 1. Install essential build tools for gems like 'pg' or 'sqlite3' +RUN apt-get update -qq && apt-get install -y \ + build-essential \ + libpq-dev \ + curl \ + git WORKDIR /usr/src/game-data -COPY Gemfile Gemfile.l*ck ./ +# 2. Set environment variables for the Gem volume we discussed +ENV BUNDLE_PATH=/usr/local/bundle \ + BUNDLE_BIN=/usr/local/bundle/bin \ + PATH=/usr/local/bundle/bin:$PATH -RUN bundle check || bundle install - -RUN gem install rake +# 3. Copy Gemfile first to leverage layer caching +COPY Gemfile Gemfile.lock ./ +RUN bundle install +# 4. Copy the application code COPY . ./ -ENTRYPOINT ["bash", "entrypoints/dev.sh"] +# 5. Make sure your entrypoint script is executable +RUN chmod +x entrypoints/dev.sh +ENTRYPOINT ["bash", "entrypoints/dev.sh"] diff --git a/entrypoints/dev.sh b/entrypoints/dev.sh index 39c792f..747d06b 100644 --- a/entrypoints/dev.sh +++ b/entrypoints/dev.sh @@ -1,7 +1,9 @@ #!/bin/bash -if [ ! -f ./data/gamedata.db ]; then - rake db:migrate -fi +# Run the migrations to make sure the DB is up-to-date +echo 'Checking database status...' +rake db:migrate +# Start the HTTP server +echo 'Starting development server...' rake server:dev