-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.fargate
53 lines (43 loc) · 1.69 KB
/
Dockerfile.fargate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM ruby:2.7 AS build-env
ARG INSTALL_PATH=/opt/app
RUN mkdir -p $INSTALL_PATH/gems
# Install Nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg -o /root/yarn-pubkey.gpg && apt-key add /root/yarn-pubkey.gpg
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y --no-install-recommends nodejs yarn
WORKDIR $INSTALL_PATH
RUN gem install rails bundler unicorn
COPY . .
ENV BUNDLER_WITHOUT "development test assets"
RUN bundle install && yarn install
# fake db url to get pass assets:precompile
# ENV DATABASE_URL "postgresql://ror6:mydbpassword@postgres:5432/testdb"
# ENV RAILS_ENV test
# RUN rm -rf public/assets && rails webpacker:install && rails assets:precompile && rm -rf node_modules
RUN rm -rf public/assets && rails webpacker:install && RAILS_ENV=development rake assets:precompile && rm -rf node_modules
############### end build ###############
FROM ruby:2.7-slim-buster
ARG PACKAGES="tzdata postgresql-client nodejs bash"
ARG INSTALL_PATH=/opt/app
WORKDIR $INSTALL_PATH
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y $PACKAGES
COPY --from=build-env /usr/local/bundle/ /usr/local/bundle/
COPY --from=build-env $INSTALL_PATH $INSTALL_PATH
RUN chown -R nobody:nogroup $INSTALL_PATH
EXPOSE 8010
ENV LISTEN_ON 0.0.0.0:8010
ENV WORKER_PROCESSES 10
ENV RAILS_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV SECRET_KEY_BASE XYZZZZZZZZZZ
# ENV DATABASE_URL
# ENV REDIS_URL
ENV DATABASE_HOST postgres
ENV DATABASE_PORT 5432
ENV PRODUCTION_DATABASE mydb
ENV DATABASE_USERNAME postgres
ENV DATABASE_PASSWORD password
USER nobody
CMD bundle exec rake db:setup ; bundle exec unicorn -c config/unicorn.rb