Skip to content

Instantly share code, notes, and snippets.

@caio-nas
Created April 16, 2023 23:18
Show Gist options
  • Save caio-nas/403e919ef764f2809e7d5c6c2adf5774 to your computer and use it in GitHub Desktop.
Save caio-nas/403e919ef764f2809e7d5c6c2adf5774 to your computer and use it in GitHub Desktop.
FROM alpine:3.16
USER root
ENV INITSYSTEM on
ENV UDEV=1
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
ENV BUNDLER_VERSION=2.4.12
ENV NODE_VERSION=14.20.0
ENV YARN_VERSION=1.22.17
ENV PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH
ENV RBENV_ROOT=/usr/local/rbenv
ENV RUBY_VERSION=3.1.3
ENV PIN_CHROME_VERSION=112.0.5615.49
ENV PIN_CHROME_RELEASE=r2
ENV install='apk add --no-cache'
RUN rm -rf /var/cache/*
RUN mkdir /var/cache/apk
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories
RUN apk update && apk upgrade -U -a
RUN $install chromium=${PIN_CHROME_VERSION}-${PIN_CHROME_RELEASE}
RUN $install chromium-chromedriver=${PIN_CHROME_VERSION}-${PIN_CHROME_RELEASE}
RUN $install nmap
RUN $install libstdc++
RUN $install pango
RUN $install glib
RUN $install libpq-dev
RUN $install libnotify
RUN $install mesa-egl
RUN $install mesa-gles
RUN $install harfbuzz@edge
RUN $install nss@edge
RUN $install freetype
RUN $install ttf-freefont
RUN $install font-noto-emoji
RUN $install wqy-zenhei
RUN $install xvfb
RUN $install libxscrnsaver
RUN $install alsa-lib
RUN $install xkbcomp
RUN $install imagemagick-dev
RUN $install libffi-dev
RUN $install git
RUN $install bash
RUN $install tar
RUN $install xz
RUN $install openssh
WORKDIR /usr/bin
RUN wget -O node-v${NODE_VERSION}-linux-x64-musl.tar.xz https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.xz
RUN tar -xf node-v${NODE_VERSION}-linux-x64-musl.tar.xz
RUN ln -s /usr/bin/node-v${NODE_VERSION}-linux-x64-musl/bin/npm /bin/npm
RUN ln -s /usr/bin/node-v${NODE_VERSION}-linux-x64-musl/bin/node /bin/node
RUN wget -O yarn.tar.gz https://yarnpkg.com/downloads/${YARN_VERSION}/yarn-v${YARN_VERSION}.tar.gz
RUN tar -xzf yarn.tar.gz
RUN ln -s /usr/bin/yarn-v${YARN_VERSION}/bin/yarn /bin/yarn
WORKDIR /app
RUN apk add --update --no-cache --virtual .ruby-builddeps \
autoconf \
bison \
bzip2 \
bzip2-dev \
ca-certificates \
coreutils \
dpkg-dev dpkg \
g++ \
gcc \
gdbm-dev \
libc-dev \
libxml2-dev \
libxslt-dev \
make \
ncurses-dev \
openssl \
openssl-dev \
patch \
procps \
readline-dev \
yaml-dev \
zlib-dev \
build-base \
icu-dev \
tzdata
RUN git clone --depth 1 https://github.com/sstephenson/rbenv.git ${RBENV_ROOT} \
&& git clone --depth 1 https://github.com/sstephenson/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build \
&& git clone --depth 1 https://github.com/jf/rbenv-gemset.git ${RBENV_ROOT}/plugins/rbenv-gemset \
&& ${RBENV_ROOT}/plugins/ruby-build/install.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN rbenv install $RUBY_VERSION && \
rbenv global $RUBY_VERSION
RUN gem install bundler -v $BUNDLER_VERSION
RUN gem install tzinfo-data
COPY Gemfile /app
COPY Gemfile.lock /app
COPY .ruby-version /app
# TODO: make bundle cache volume work
# RUN bin/bundle config set --global path '/var/lib/bundle'
RUN bundle check || bundle install --jobs=$(nproc)
COPY package.json /app
COPY yarn.lock /app
COPY .npmrc /app
RUN /bin/yarn install --check-files
RUN mkdir -p tmp/pids
RUN mkdir -p /root/.webdrivers
RUN ln -s /usr/lib/chromium/chromedriver /root/.webdrivers/chromedriver
COPY ./docker/entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment