Skip to content

Commit

Permalink
Fix docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Feb 21, 2024
1 parent f1b2813 commit 57db12c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
48 changes: 29 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@ ARG BUILD_SCRIPT="set -uex \
&& echo \"deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main\" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install nodejs -y \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg -o /root/yarn-pubkey.gpg \
&& apt-key add /root/yarn-pubkey.gpg \
&& echo \"deb https://dl.yarnpkg.com/debian/ stable main\" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends nodejs \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log \
&& npm install -g npm \
&& npm install -g yarn \
&& yarn set version 1.22.10"
&& yarn set version 1.22.19"
ARG BUNDLE_WITHOUT="development:metrics:test"
ARG BUNDLER_VERSION="2.3.12"
ARG POST_BUILD_SCRIPT="yarn && bundle exec rails assets:precompile"
ARG BUNDLER_VERSION="2.4.18"
ARG POST_BUILD_SCRIPT="bundle exec rails assets:precompile"
ARG RAILS_DB_ADAPTER="nulldb"
ARG SKIP_MEMCACHE_CHECK="true"
ARG RAILS_ENV="production"
ARG SECRET_KEY_BASE="thisneedstobeset"
Expand All @@ -42,6 +34,17 @@ RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y ${BUILD_PACKAGES}

# Installs nodejs as a dependency
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg -o /root/yarn-pubkey.gpg && apt-key add /root/yarn-pubkey.gpg \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ && apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
nodejs \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log

RUN [[ ${BUILD_SCRIPT} ]] && bash -c "${BUILD_SCRIPT}"

# Install specific versions of dependencies
Expand All @@ -50,22 +53,29 @@ RUN gem install bundler:${BUNDLER_VERSION} --no-document
# TODO: Load artifacts

# set up app-src directory
COPY . /app-src
COPY ./Gemfile ./Gemfile.lock /app-src/
WORKDIR /app-src

# Run deployment
RUN bundle config set --local deployment 'true' \
&& bundle config set --local without ${BUNDLE_WITHOUT} \
&& bundle package \
&& bundle install \
&& bundle clean
RUN bundle config set --local deployment 'true' \
&& bundle config set --local without ${BUNDLE_WITHOUT} \
&& bundle package \
&& bundle install \
&& bundle clean

COPY ./package.json ./yarn.lock /app-src/
RUN yarn

# set up app-src directory
COPY . /app-src

RUN [[ ${POST_BUILD_SCRIPT} ]] && bash -c "${POST_BUILD_SCRIPT}"

# TODO: Save artifacts

RUN rm -rf vendor/cache/ .git


##################################################################
# Run Stage #
##################################################################
Expand All @@ -80,7 +90,7 @@ SHELL ["/bin/bash", "-c"]
RUN adduser --disabled-password --uid 1001 --gid 0 --gecos "" --shell /bin/bash app

ARG BUNDLE_WITHOUT="development:metrics:test"
ARG BUNDLER_VERSION="2.3.12"
ARG BUNDLER_VERSION="2.4.18"
ARG RUN_PACKAGES="clamav clamav-daemon git graphicsmagick libicu-dev libpq5 nodejs poppler-utils"
ARG CUSTOMIZATION_OUTPUT="false"
ENV TZ="Europe/Zurich"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gem 'decidim-navigation_maps', github: 'Platoniq/decidim-module-navigation_maps'
# TODO: These are not updated yet :(
# gem 'decidim-navbar_links', github: 'puzzle/decidim-module-navbar_links', tag: "v#{DECIDIM_VERSION}"
# gem 'decidim-url_aliases', github: 'OpenSourcePolitics/decidim-urlaliases'

gem 'activerecord-nulldb-adapter'
gem 'acts_as_textcaptcha'
gem 'aws-sdk-s3', require: false
gem 'binding_of_caller'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ GEM
activerecord (6.1.7.6)
activemodel (= 6.1.7.6)
activesupport (= 6.1.7.6)
activerecord-nulldb-adapter (1.0.1)
activerecord (>= 5.2.0, < 7.2)
activestorage (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
Expand Down Expand Up @@ -990,6 +992,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activerecord-nulldb-adapter
acts_as_textcaptcha
aws-sdk-s3
better_errors
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# On Linux, the 'host: "localhost"' line below should be commented out to avoid 'password required' error.
#
default: &default
adapter: postgresql
adapter: <%= ENV.fetch('RAILS_DB_ADAPTER', 'postgresql') %>
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
Expand Down

0 comments on commit 57db12c

Please sign in to comment.