forked from ywwg/ffagc
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (55 loc) · 2.22 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (55 loc) · 2.22 KB
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
# #####################################################################
# Stage 1: Install gems and precompile assets.
# #####################################################################
FROM ruby:3.3-slim AS build
WORKDIR /app
# Base build deps (include ca-certificates so curl TLS is happy)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gnupg \
build-essential \
libpq-dev \
libyaml-dev \
libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
# Node 20 repo (NodeSource)
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg && \
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
# Install Node (and use Corepack for Yarn instead of Yarn APT repo)
RUN apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/* && \
corepack enable
# If your project expects classic Yarn (v1), keep this:
RUN corepack prepare yarn@1.22.22 --activate
# If it expects modern Yarn (berry), swap to something like:
# RUN corepack prepare yarn@4.5.3 --activate
# Install gems into vendor/bundle
COPY Gemfile Gemfile.lock /app/
RUN bundle config set --local path "vendor/bundle" && \
bundle install --jobs 4 --retry 3
# If you actually need JS deps for assets, uncomment these:
# COPY package.json yarn.lock /app/
# RUN yarn install --frozen-lockfile
# Copy app and precompile assets (SECRET_KEY_BASE only for this command)
COPY . /app/
RUN SECRET_KEY_BASE=dummy_precompile_secret bin/rails assets:precompile
RUN chown -R www-data:www-data /app
# #####################################################################
# Stage 2: Runtime
# #####################################################################
FROM ruby:3.3-slim
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq5 \
libsqlite3-0 \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN bundle config set --local path "vendor/bundle"
USER www-data:www-data
COPY --from=build /app /app/
EXPOSE 3000
CMD ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]