Last active
May 6, 2021 05:04
-
-
Save nejdetkadir/e3eea6f79fc8bf05cb20905132b005d0 to your computer and use it in GitHub Desktop.
Docker basics for Ruby on Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
db: | |
image: postgres:latest | |
restart: always | |
environment: | |
- POSTGRES_PASSWORD=password | |
ports: | |
- "5432:5432" | |
volumes: | |
- "dbdata:/var/lib/postgresql/data" | |
redis: | |
image: redis:latest | |
ports: | |
- "6379:6379" | |
web: | |
build: . | |
ports: | |
- "3000:3000" | |
depends_on: | |
- db | |
- redis | |
environment: | |
- DATABASE_URL=postgres://postgres:password@db:5432/postgres | |
- REDIS_URL=redis://redis:6379 | |
volumes: | |
- .:/app | |
volumes: | |
dbdata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:3.0.0-alpine | |
RUN apk add --update --virtual \ | |
runtime-deps \ | |
postgresql-dev \ | |
postgresql-client \ | |
build-base \ | |
libxml2-dev \ | |
libxslt-dev \ | |
nodejs \ | |
yarn \ | |
libffi-dev \ | |
readline \ | |
libc-dev \ | |
linux-headers \ | |
readline-dev \ | |
file \ | |
imagemagick \ | |
git \ | |
tzdata && rm -rf /var/cache/apk/* | |
WORKDIR /app | |
COPY . /app/ | |
ENV BUNDLE_PATH /gems | |
RUN yarn install | |
RUN bundle install | |
ENTRYPOINT [ "bin/rails" ] | |
EXPOSE 3000 | |
CMD [ "s", "-b", "0.0.0.0" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment