-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathDockerfile.dev
More file actions
60 lines (42 loc) · 1.57 KB
/
Dockerfile.dev
File metadata and controls
60 lines (42 loc) · 1.57 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
ARG RUBY_VERSION=4.0.1
ARG NODE_VERSION=22.7.0
# Use Node image so we can pull the binaries from here.
FROM node:$NODE_VERSION AS node
# Ruby build image.
FROM ruby:${RUBY_VERSION}-slim
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential libssl-dev libpq-dev vim git libsasl2-dev libyaml-dev curl && \
rm -rf /var/lib/apt/lists/*
# Copy node binaries from node image.
COPY --from=node /usr/local /usr/local
COPY --from=node /opt /opt
# Setup environment variables.
ENV WORK_ROOT=/src
ENV APP_HOME=$WORK_ROOT/app/
ENV LANG=C.UTF-8
ENV USERNAME=rails_api_base
ENV USER_UID=1000
ENV USER_GID=1000
# Create a rootless user.
RUN groupadd --gid "$USER_GID" "$USERNAME" && \
useradd --uid "$USER_UID" --gid "$USER_GID" -m "$USERNAME"
# Create app directory.
RUN mkdir -p "$APP_HOME" && chown -R "$USERNAME:$USERNAME" "$APP_HOME" && chmod -R 700 "$APP_HOME"
# Change to the rootless user.
USER "$USERNAME"
# Setup work directory.
WORKDIR "$APP_HOME"
RUN gem install foreman bundler
# Copy dependencies files and install libraries.
COPY --link --chown="$USERNAME:$USERNAME" --chmod=700 package.json yarn.lock .yarnrc.yml ./
RUN corepack enable
RUN yarn install --immutable && yarn cache clean
COPY --link --chown="$USERNAME:$USERNAME" --chmod=700 Gemfile Gemfile.lock .ruby-version ./
RUN bundle install -j 4
COPY --link --chown="$USERNAME:$USERNAME" --chmod=700 . .
RUN yarn build
# Entrypoint prepares the database.
ENTRYPOINT ["./bin/docker-entrypoint"]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/dev"]