Last active
February 12, 2023 22:28
-
-
Save jeremiahlukus/41f14a1f6747612f552fbdde35e7e1d1 to your computer and use it in GitHub Desktop.
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
Running with Docker Compose | |
A sample Docker Compose configuration that runs Rails, Postgresql, and Redis. | |
Simply run: | |
docker-compose up | |
Then open http://localhost:3000 | |
Running with Docker | |
If you'd like to run with Docker directly, you can run: | |
docker build --tag myapp . | |
docker run -p 3000:3000 myapp |
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.2' | |
services: | |
db: | |
image: postgres:latest | |
environment: | |
- POSTGRES_PASSWORD=password | |
ports: | |
- "5432:5432" | |
volumes: | |
- "dbdata:/var/lib/postgresql/data" | |
redis: | |
image: redis:alpine | |
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 | |
- PORT=3000 | |
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.2 | |
RUN gem install "bundler:~>2" --no-document && \ | |
gem update --system && \ | |
gem cleanup | |
# NodeJS (https://github.com/nodejs/docker-node/blob/main/14/bullseye/Dockerfile) | |
ARG NODE_VERSION=18.14.0 | |
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ | |
&& case "${dpkgArch##*-}" in \ | |
amd64) ARCH='x64';; \ | |
ppc64el) ARCH='ppc64le';; \ | |
s390x) ARCH='s390x';; \ | |
arm64) ARCH='arm64';; \ | |
armhf) ARCH='armv7l';; \ | |
i386) ARCH='x86';; \ | |
*) echo "unsupported architecture"; exit 1 ;; \ | |
esac \ | |
# gpg keys listed at https://github.com/nodejs/node#release-keys | |
&& set -ex \ | |
&& for key in \ | |
4ED778F539E3634C779C87C6D7062848A1AB005C \ | |
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ | |
74F12602B6F1C4E913FAA37AD3A89613643B6201 \ | |
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ | |
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ | |
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ | |
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ | |
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ | |
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ | |
108F52B48DB57BB0CC439B2997B01419BD92F80A \ | |
B9E2F5981AA6E0CD28160D9FF13993A75599653C \ | |
; do \ | |
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ | |
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ | |
done \ | |
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \ | |
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ | |
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ | |
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ | |
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ | |
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \ | |
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \ | |
# smoke tests | |
&& node --version \ | |
&& npm --version | |
ARG YARN_VERSION=1.22.19 | |
RUN set -ex \ | |
&& for key in \ | |
6A010C5166006599AA17F08146C2130DFD2497F5 \ | |
; do \ | |
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ | |
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ | |
done \ | |
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ | |
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ | |
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ | |
&& mkdir -p /opt \ | |
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ | |
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ | |
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ | |
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ | |
# smoke test | |
&& yarn --version | |
# App dependencies | |
RUN apt-get update -qq && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends imagemagick libvips libvips-dev libvips-tools libpq-dev poppler-utils && \ | |
rm -rf /var/lib/apt/lists/* /var/cache/apt | |
# App | |
WORKDIR /app | |
COPY ./Gemfile* /app/ | |
RUN bundle config --local without "staging production omit" && bundle install --jobs $(nproc) --retry 5 | |
COPY package.json yarn.lock /app/ | |
RUN yarn install | |
COPY . /app | |
CMD ["bin/rails", "s", "-b", "0.0.0.0"] | |
EXPOSE 3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment