我跟随https://medium.com/soulmates-ai/running-a-rails-app-with-webpacker-and-docker-8d29153d3446,将Webpacker和Rails用作单独的服务,使我的Rails项目适应Docker。
作为菜鸟,我将很高兴能给我一些时间来回顾这些内容,并告诉我我是否做得正确:)
Dockerfile
FROM ruby:2.5.5-slim
ARG PRECOMPILEASSETS
ARG RAILS_ENV
ENV RAILS_ENV ${RAILS_ENV}
RUN apt-get update && apt-get install -y curl gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN curl -q https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get -y update && \
apt-get install --fix-missing --no-install-recommends -qq -y \
build-essential \
vim \
wget gnupg \
git-all \
curl \
ssh \
postgresql-client-10 libpq5 libpq-dev -y && \
wget -qO- https://deb.nodesource.com/setup_9.x | bash - && \
apt-get install -y nodejs && \
wget -qO- 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 yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN gem install bundler
#Install gems
RUN mkdir /gems
WORKDIR /gems
COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install
ARG INSTALL_PATH=/opt/beweeg
ENV INSTALL_PATH $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY . .
# Precompile assets (or not)
RUN docker/potential_asset_precompile.sh $PRECOMPILEASSETS
docker-compose.yml
version: '3.0'
services:
db:
image: postgres:11-alpine
ports:
- 5433:5432
environment:
POSTGRES_PASSWORD: postgres
webpacker:
image: ${DOCKER_IMAGE_NAME-beweeg}
command: ["./docker/start_webpack_dev.sh"]
volumes:
- .:/opt/beweeg:cached
ports:
- 3035:3035
app:
image: ${DOCKER_IMAGE_NAME-beweeg}
build:
context: .
args:
- PRECOMPILEASSETS=NO
- RAILS_ENV=development
environment:
- RAILS_ENV=development
- APP_HOST=localhost:3000
- SMTP_USERNAME
- SMTP_PWD
- SMTP_DOMAIN
- SMTP_ADDRESS
- SMTP_PORT
- SMTP_AUTHENTICATION
- SMTP_ENABLE_STARTTLS_AUTO
links:
- db
- webpacker
ports:
- 3000:3000
command: ["./docker/wait_for_it.sh", "db:5432", "--", "./docker/start_rails.sh"]
volumes:
- .:/opt/beweeg:cached
.dockerignore
.git
.gitignore
*.md
.dockerignore
.gitlab-ci.yml
docker-compose.*
Dockerfile
log/*
node_modules/*
public/assets/*
storage/*
public/js/*
public/js-test/*
tmp/*
其余部分应该与《灵魂伴侣》的相关文章中的内容完全相同...您怎么看? NB:这个项目是私人的,这就是为什么我不能完全共享它的原因……对此感到抱歉。如果需要更多资源,请告诉我,我将尝试制作一个模拟假项目:)
提前谢谢