-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
52 lines (39 loc) · 1.5 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
ARG BASE_IMAGE
FROM ${BASE_IMAGE:-ruby:3.3.6-alpine3.21} AS ruby-builder
RUN apk --no-cache add build-base cmake postgresql17-dev git
COPY Gemfile Gemfile.lock ./
RUN gem i foreman && bundle install \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
FROM node:22-alpine3.21 AS node-downloader
RUN npm install [email protected] -g
FROM ${BASE_IMAGE:-ruby:3.3.6-alpine3.21}
WORKDIR /app
RUN apk --no-cache add \
tzdata \
postgresql17-client \
vips ffmpeg \
sudo jemalloc
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
ENV RUBYOPT=--enable=frozen-string-literal
RUN echo "[safe]" > ~/.gitconfig && \
echo " directory = /app" >> ~/.gitconfig
# Create a user with (potentially) the same id as on the host
ARG HOST_UID=1000
ARG HOST_GID=1000
RUN addgroup --gid ${HOST_GID} reverser && \
adduser -S --shell /bin/sh --uid ${HOST_UID} reverser -G reverser && \
addgroup reverser wheel && \
echo "reverser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
ARG DOCKER_RUN_AS_USER
ENV USER=${DOCKER_RUN_AS_USER:+reverser}
ENV USER=${USER:-root}
USER $USER
# Copy native npm package binaries
COPY --from=node-downloader /usr/local/lib/node_modules/esbuild/bin/esbuild /usr/local/bin
# Copy gems
COPY --from=ruby-builder /usr/local/bundle /usr/local/bundle
# Bust cache if local git ref changes and add it to the image
# This looks weird but handles the .git folder missing entirely
ADD .gi?/ref?/head?/maste? /docker/git_master_ref