-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (45 loc) · 1.77 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (45 loc) · 1.77 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
ARG APP_ROOT=/app
ARG BUNDLE_PATH=/bundler
ARG PACKAGES_RUNTIME=""
ARG RUBY_VERSION="3.2.2"
################################################################################
# Base configuration
#
FROM ruby:$RUBY_VERSION-slim-bullseye AS builder-base
ARG APP_ROOT
ARG BUNDLE_PATH
ARG PACKAGES_BUILD="build-essential git"
ENV BUNDLE_PATH=$BUNDLE_PATH
ENV BUNDLE_BIN="$BUNDLE_PATH/bin"
ENV PATH="$BUNDLE_BIN:$PATH"
WORKDIR $APP_ROOT
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends $PACKAGES_BUILD && \
apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
gem install bundler --no-document
COPY Gemfile Gemfile.lock $APP_ROOT/
################################################################################
# Development image
#
FROM builder-base AS development
ARG GEMS_DEV="pessimizer"
ARG PACKAGES_DEV="zsh curl wget sudo"
ARG PACKAGES_RUNTIME
ARG USERNAME=developer
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends $PACKAGES_DEV $PACKAGES_RUNTIME && \
apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
gem install $GEMS_DEV && \
addgroup --gid $USER_GID $USERNAME && \
adduser --home /home/$USERNAME --shell /bin/zsh --uid $USER_UID --gid $USER_GID $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && \
mkdir -p $BUNDLE_PATH && \
chown -R $USERNAME:$USERNAME $BUNDLE_PATH && \
chown -R $USERNAME:$USERNAME $APP_ROOT
USER $USERNAME
RUN bundle install --jobs 4 --retry 3
WORKDIR /home/$USERNAME
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.2/zsh-in-docker.sh)"
WORKDIR $APP_ROOT