forked from xxwhirlpool/spring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
executable file
·71 lines (55 loc) · 1.96 KB
/
Copy pathContainerfile
File metadata and controls
executable file
·71 lines (55 loc) · 1.96 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
68
69
70
71
FROM ruby:3.2.3
USER root
ARG UID=1000
ARG GID=1000
ARG NODE_MAJOR=20
ARG BUNDLER_VERSION=2.5.5
ENV TZ=UTC
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=true
ENV SITE_NAME=NightSpring
ENV APP_NAME=NightSpring
ENV APP_TITLE=NightSpring
ENV HOSTNAME=nightspring.net
# Install secure dependencies for Node and Yarn
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
curl gnupg2 ca-certificates lsb-release
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
# Install system dependencies
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
build-essential libpq-dev postgresql-client \
libxml2-dev libxslt1-dev libmagickwand-dev imagemagick \
libidn11-dev tzdata nodejs yarn git \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
RUN mkdir -p /app /cache
WORKDIR /app
# Create and assign non-root user
RUN addgroup --gid ${GID} app \
&& adduser --gecos "" --disabled-password --shell /bin/bash --uid ${UID} --gid ${GID} app \
&& chown -R app:app /app /cache
# Add entrypoint
COPY .docker/entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
# Install Ruby dependencies before copying full app (cache optimization)
COPY Gemfile Gemfile.lock ./
RUN gem install bundler:$BUNDLER_VERSION \
&& bundle config set without 'development test' \
&& bundle install --jobs=$(nproc)
# Install JavaScript packages
COPY package.json yarn.lock ./
RUN yarn install --immutable
# Copy full application source
COPY . .
# Remove non-English locales to reduce final image size
RUN find config/locales -type f ! -name '*.en.yml' -delete
# Set ownership again post-copy
RUN chown -R app:app /app
# Switch to app user for security
USER app:app
# Expose port and launch Rails
EXPOSE 3000
ENTRYPOINT ["entrypoint.sh"]
CMD ["rails", "server", "-b", "0.0.0.0"]