From ba482c985771876416b97e14c80a4f6985ca410f Mon Sep 17 00:00:00 2001 From: drunken-boat Date: Sun, 4 Aug 2024 12:38:48 -0400 Subject: [PATCH] fix: add dockerfile --- Dockerfile.app | 50 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 45 +++++++++++++++++++++++------------------ 2 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 Dockerfile.app diff --git a/Dockerfile.app b/Dockerfile.app new file mode 100644 index 00000000..92eff9cb --- /dev/null +++ b/Dockerfile.app @@ -0,0 +1,50 @@ +# Use the official Ruby image as the base image +FROM ruby:3 + +# Install dependencies +RUN apt-get update -qq && apt-get install -y curl gnupg2 + +# Install Node.js (specific version) +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs=18.18.0-1nodesource1 + +# Install Yarn +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ + && apt-get update && apt-get install -y yarn + +# Set an environment variable where the Rails app is installed to inside of Docker image +ENV RAILS_ROOT /var/www/app +RUN mkdir -p $RAILS_ROOT + +# Set working directory +WORKDIR $RAILS_ROOT + +# Setting env up +ENV RAILS_ENV='development' +ENV RACK_ENV='development' + + +# Install the compatible version of bundler +RUN gem install bundler + +# Copy the Gemfile and Gemfile.lock +COPY Gemfile Gemfile.lock ./ + +# Install gems +RUN bundle install + +# Copy the main application +COPY . . + +# Install JavaScript dependencies +RUN yarn install + +# Precompile assets +RUN bundle exec rake assets:precompile + +# Expose port 3000 to the Docker host, so we can access it from the outside. +EXPOSE 3000 + +# The command to run the application +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/docker-compose.yml b/docker-compose.yml index a6dc292d..08f577ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,35 @@ version: '3.7' - services: - postgres: - image: 'postgres:14.8-alpine' - volumes: - - 'pgdata:/var/lib/postgresql/data' + db: + image: postgres:13 environment: - - POSTGRES_USER=sm - - POSTGRES_PASSWORD=sm_password + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: mydatabase ports: - - 5432:5432 - redis-sidekiq: - image: redis:6.2.13-alpine - ports: - - 6379:6379 - redis-cache: - image: redis:6.2.13-alpine + - "5432:5432" + + redis: + image: redis:6 ports: - - 6380:6379 + - "6379:6379" + mailcatcher: image: schickling/mailcatcher ports: - - 1025:1025 - - 1080:1080 + - "1080:1080" -volumes: - pgdata: + app: + build: + context: . + dockerfile: Dockerfile.app + ports: + - "3000:3000" + depends_on: + - db + - redis + - mailcatcher + env_file: + - .env + volumes: + - .:/app