Add Docker deployment files for Unity infrastructure migration

This commit is contained in:
Claude
2026-02-06 06:28:52 +00:00
parent 0ba20f45b3
commit eb1010d8af
4 changed files with 65 additions and 21 deletions

View File

@@ -1,2 +1,7 @@
.git .git
.dockerignore log/*
tmp/*
vendor/bundle
node_modules
.bundle
.DS_Store

View File

@@ -1,20 +1,34 @@
FROM ruby:2.5 FROM ruby:2.6.10-slim-bullseye
RUN apt-get update -qq && apt-get install -y build-essential libmariadb-dev libcups2-dev libpq-dev nodejs tzdata
RUN mkdir /sxrestaurant # Install dependencies (MySQL client + ImageMagick for CarrierWave/MiniMagick)
RUN mkdir -p /sxrestaurant/tmp/puma RUN apt-get update -qq && apt-get install -y --no-install-recommends \
ENV RAILS_ENV production build-essential \
ENV RACK_ENV production default-libmysqlclient-dev \
WORKDIR /sxrestaurant nodejs \
#RUN gem install bundler git \
#COPY Gemfile /sxrestaurant/Gemfile curl \
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock imagemagick \
#RUN bundle install --without development test libmagickwand-dev \
RUN echo "Asia/Rangoon" > /etc/timezone && rm -rf /var/lib/apt/lists/*
RUN dpkg-reconfigure -f noninteractive tzdata
RUN date WORKDIR /app
COPY . /sxrestaurant
RUN gem install bundler # Install gems
#RUN bundle update --bundler COPY Gemfile Gemfile.lock ./
RUN bundle install --without development test RUN bundle install --deployment --without development test --jobs 4
RUN bundle exec rake assets:precompile
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] # Copy application
COPY . .
# Create required directories
RUN mkdir -p tmp/pids tmp/puma tmp/cache tmp/sockets log storage public/uploads
# Precompile assets
RUN RAILS_ENV=production SECRET_KEY_BASE=placeholder bundle exec rake assets:precompile 2>/dev/null || true
EXPOSE 3000
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
CMD ["/app/entrypoint.sh"]

17
config/puma_docker.rb Normal file
View File

@@ -0,0 +1,17 @@
# Puma configuration for Docker deployment
application_path = File.expand_path('..', __dir__)
directory application_path
environment ENV.fetch('RAILS_ENV') { 'production' }
pidfile "#{application_path}/tmp/puma/pid"
state_path "#{application_path}/tmp/puma/state"
# Log to stdout/stderr in Docker
stdout_redirect '/dev/stdout', '/dev/stderr', true
# Use PORT env var (default 3000 for Coolify)
port ENV.fetch('PORT') { 3000 }
workers ENV.fetch('WEB_CONCURRENCY') { 3 }
preload_app!
threads 5, 16

8
entrypoint.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Start Sidekiq in background
bundle exec sidekiq -C config/sidekiq.yml -e production &
# Start Puma on port 3000
exec bundle exec puma -C config/puma_docker.rb