# docker/webapp/Dockerfile
FROM ruby:2.6.6
SHELL ["/bin/bash", "-c"]
RUN apt-get update -qq && apt-get install -y postgresql-client memcached tzdata nano
# Install node 12, yarn
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y yarn nodejs
# Rails app
ENV DIR /var/www/webapp
RUN mkdir -p $DIR
WORKDIR $DIR
COPY Gemfile $DIR/Gemfile
COPY Gemfile.lock $DIR/Gemfile.lock
RUN gem install bundler:2.0.2
RUN bundle install
COPY package.json $DIR/package.json
COPY yarn.lock $DIR/yarn.lock
RUN yarn install --check-files
ARG CACHEBURST=1
ADD . $DIR
# Add a script to be executed every time the container starts.
COPY docker/webapp/entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
ENV PATH=./bin:$PATH
# Start the main process.
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
# ./docker-compose.yml
version: '3.8'
services:
webapp:
tty: true
stdin_open: true
image: chilling.dev:latest
build:
context: .
dockerfile: docker/webapp/Dockerfile
volumes:
- ./:/var/www/webapp
- node-modules:/var/www/webapp/node_modules
- gems:/usr/local/bundle
depends_on:
- postgres
environment:
- RAILS_ENV
ports:
- 3000:3000
postgres:
image: postgres:12.3
volumes:
- pg-data:/var/lib/postgresql/data
ports:
- 15432:5432
environment:
- POSTGRES_USER=chilling.dev
- POSTGRES_PASSWORD=chilling.dev.hunt#1995
webpacker:
image: chilling.dev:latest
command: ["yarn", "start"]
volumes:
- ./:/var/www/webapp
- node-modules:/var/www/webapp/node_modules
- gems:/usr/local/bundle
ports:
- 3035:3035
spring:
image: chilling.dev:latest
command: ["spring", "server"]
volumes:
- ./:/var/www/webapp
- node-modules:/var/www/webapp/node_modules
- gems:/usr/local/bundle
environment:
- POSTGRES_USER=chilling.dev
- POSTGRES_PASSWORD=chilling.dev.hunt#1995
- RAILS_ENV
volumes:
node-modules:
gems:
pg-data: