-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-rbenv_nvm
118 lines (95 loc) · 3.6 KB
/
Dockerfile-rbenv_nvm
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
FROM ubuntu:24.04
RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
ca-certificates-java \
curl \
git \
gnupg \
jq \
locales \
lsb-release \
libffi-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libvips \
libyaml-dev \
openjdk-11-jre \
openssh-client \
pkg-config \
postgresql-client \
redis \
ruby-dev \
sudo \
tzdata \
vim-tiny \
wget \
zip \
zlib1g-dev
# https://github.com/jekyll/jekyll/issues/4268#issuecomment-167406574
RUN dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8
# Install needed default locale for Makefly
RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \
locale-gen
# Set default locale for the environment
ENV LC_ALL=C.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Use bash as the default shell, and specify a login shell so that .profile is
# sourced when the shell starts
SHELL ["/bin/bash", "-l", "-c"]
# Provide argument or runtime environment variable
ARG build_timezone=Etc/Universal
ENV TZ=$build_timezone
COPY --chmod=775 check_ownership.sh /usr/local/bin/check_ownership
ENTRYPOINT ["check_ownership"]
# run with `sleep infinity` if you want to keep a running container to exec to
CMD ["bash", "-l"]
# Make sure you define build_docker_uid and build_docker_gid to match the user IDs used on your system,
# so that your volume mappings work with your user
ARG build_user_name=user
ENV USER_NAME=$build_user_name
ARG build_docker_uid
RUN test -n "$build_docker_uid" || (echo "build_docker_uid not set" && false)
ARG build_docker_gid=1000
RUN test -n "$build_docker_gid" || (echo "build_docker_gid not set" && false)
RUN groupadd -g $build_docker_gid $USER_NAME
RUN useradd $USER_NAME -u $build_docker_uid -g $build_docker_gid --create-home --shell /bin/bash
RUN mkdir -p /etc/sudoers.d \
&& echo "$USER_NAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER_NAME \
&& chmod 0440 /etc/sudoers.d/$USER_NAME
USER ${USER_NAME}:${USER_NAME}
WORKDIR /home/$USER_NAME
ARG build_node_version=20.16.0
ENV NODE_VERSION=$build_node_version
ARG NVM_DIR=/home/${USER_NAME}/.nvm
ARG build_nvm_install_version=v0.40.0
ENV NVM_INSTALL_VERSION=$build_nvm_install_version
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_INSTALL_VERSION/install.sh | bash
# We need to source nvm.sh as the installer copies sourcing to .bashrc
RUN . "$NVM_DIR/nvm.sh" \
&& nvm install ${NODE_VERSION} \
&& nvm use v${NODE_VERSION} \
&& nvm alias default v${NODE_VERSION}
# Add this to .profile instead of .bashrc so that its used when bash loads
RUN echo 'PATH=$HOME/.nvm/versions/node/v${NODE_VERSION}/bin/:$PATH' \
>> /home/${USER_NAME}/.profile
ARG build_ruby_version=3.3.4
ENV RUBY_VERSION=$build_ruby_version
RUN git clone https://github.com/rbenv/rbenv.git /home/${USER_NAME}/.rbenv
RUN git clone https://github.com/rbenv/ruby-build.git /home/${USER_NAME}/.rbenv/plugins/ruby-build
# Add this to .profile instead of .bashrc so that its used when bash loads
RUN echo 'PATH=$HOME/.rbenv/plugins/ruby-build/bin:$HOME/.rbenv/bin:$PATH' \
>> /home/${USER_NAME}/.profile
RUN echo 'eval "$($HOME/.rbenv/bin/rbenv init -)"' >> /home/${USER_NAME}/.profile
# No need to source .bashrc or .profile here, as its loaded by bash
RUN rbenv install ${RUBY_VERSION} \
&& rbenv global ${RUBY_VERSION}
RUN echo 'gem: --no-document' >> /home/${USER_NAME}/.gemrc