Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix437: Containerize Soulmedicine to Docker App #467

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Dockerfile.app
Original file line number Diff line number Diff line change
@@ -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"]
45 changes: 26 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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