-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
86 lines (67 loc) · 1.87 KB
/
Dockerfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
FROM ruby:3.2 as build
ARG PORT=80
ARG APP_ROOT="/app"
ARG NVM_VERSION="v0.39.3"
ARG NVM_DIR="/usr/local/nvm"
ARG NODE_VERSION="v20.1.0"
ARG YARN_VERSION="v1.22.19"
ENV RAILS_ENV=production
ENV NODE_ENV=development
ENV APP_ROOT $APP_ROOT
ENV BUNDLE_APP_CONFIG=$APP_ROOT/.bundle
# Install Packages
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
build-essential \
default-jre \
curl \
bash \
libxml2-dev \
libxslt-dev && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/*
# Install NVM
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh | bash
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION"
ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/bin
ENV PATH $NODE_PATH:$PATH
RUN npm -v
RUN node -v
# Install Yarn
RUN npm install --global yarn@$YARN_VERSION
RUN yarn -v
# Create working directory
RUN mkdir -p $APP_ROOT
WORKDIR $APP_ROOT
# Copy files for installing packages
COPY . .
# Install Ruby Packages
RUN bundle config set --local path $BUNDLE_APP_CONFIG
RUN bundle config --local build.nokogiri --use-system-libraries
RUN gem install bundler
RUN bundle install --jobs 4 --retry 3
# Install Node Packages
Run yarn install
# Build assests
RUN bin/rails assets:precompile
# Clean up
RUN rm -rf node_modules tmp logs test/dummy/tmp test/dummy/logs
FROM ruby:3.2
ARG PORT=80
ARG APP_ROOT="/app"
ENV RAILS_ENV=production
ENV APP_ROOT $APP_ROOT
ENV APP_PORT $PORT
ENV BUNDLE_APP_CONFIG=$APP_ROOT/.bundle
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
build-essential \
libxml2-dev \
libxslt-dev && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/*
WORKDIR $APP_ROOT
COPY --from=build $APP_ROOT $APP_ROOT
EXPOSE $PORT
CMD bin/rails server -b 0.0.0.0 -p ${APP_PORT}