diff --git a/.docker-files/deps.sh b/.docker-files/deps.sh index 4cc2701..d371b31 100644 --- a/.docker-files/deps.sh +++ b/.docker-files/deps.sh @@ -8,14 +8,5 @@ apt-get update -qq \ curl \ less \ git \ - vim \ - zlib1g-dev \ - apt-transport-https \ - ca-certificates \ - libgnutls30 \ - libvips42 - #software-properties-common - -#add-apt-repository ppa:chris-needham/ppa -#apt-get update -#apt-get install audiowaveform + libvips42 \ + zlib1g-dev diff --git a/.docker-files/node.sh b/.docker-files/node.sh index ccf73a7..1060461 100644 --- a/.docker-files/node.sh +++ b/.docker-files/node.sh @@ -1,24 +1,17 @@ set -x # Add NodeJS to sources list -# curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash - -# curl -sL https://deb.nodesource.com/setup_18.x | bash - +curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash - -curl -fsSL https://deb.nodesource.com/setup_stable.x | bash - &&\ -apt-get install -y nodejs +# Add Yarn to the sources list +#curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ +# && echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list -# apt-get install -y nodejs #to install Node.js 18.x and npm +# Install NodeJS, Yarn +apt-get update -qq && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq nodejs +# yarn=$YARN_VERSION-1 -#17 10.80 ## You may also need development tools to build native addons: -#apt-get install gcc g++ make -#17 10.80 ## To install the Yarn package manager, run: -#curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null -#echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list -#apt-get update && apt-get install yarn -#npm install --global yarn - -#corepack enable -#echo yarn -v - -# yarn install +corepack enable +corepack prepare yarn@stable --activate diff --git a/.docker-files/pg.sh b/.docker-files/pg.sh index 5f6a250..1ad29b0 100644 --- a/.docker-files/pg.sh +++ b/.docker-files/pg.sh @@ -5,20 +5,9 @@ set +x # && echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list # Install PostgreSQL client and libs -#apt-get update -qq && \ -# DEBIAN_FRONTEND=noninteractive apt-get install -yq libpq-dev \ -# postgresql-client-$PG_MAJOR +apt-get update -qq && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq libpq-dev \ + default-mysql-client \ + libmariadb-dev-compat - -# Create the file repository configuration: -sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' - -# Import the repository signing key: -wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - - -# Update the package lists: -apt-get update - -# Install the latest version of PostgreSQL. -# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql': -apt-get -yq install postgresql \ No newline at end of file +# default-libmysqlclient-dev diff --git a/Dockerfile b/Dockerfile index f7e901b..7a4116b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,12 @@ -# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of -# Alpine to avoid DNS resolution issues in production. -# -# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu -# https://hub.docker.com/_/ubuntu?tab=tags -# -# -# This file is based on these images: -# -# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image -# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20220801-slim - for the release image -# - https://pkgs.org/ - resource for finding needed packages -# - Ex: hexpm/elixir:1.13.4-erlang-25.0.4-debian-bullseye-20220801-slim -# -ARG RUBY_VERSION=3.2.0 -ARG OTP_VERSION=25.0.4 -ARG DISTRO=ubuntu -ARG DEBIAN_VERSION=bionic-20210930 -ARG DEFAULT_LOCALE=en - -ARG PG_MAJOR=14 -ARG NODE_MAJOR=18 -ARG YARN_VERSION=1.13.0 - -ARG BUILDER_IMAGE="ruby:$RUBY_VERSION-slim-buster" -ARG RUNNER_IMAGE="${DISTRO}:${DEBIAN_VERSION}" - -FROM ${BUILDER_IMAGE} as builder +#ARG RUBY_VERSION +FROM ruby:3.2.0-bullseye +ARG APP_ENV=production + +ARG PG_MAJOR +ARG NODE_MAJOR=16 +ARG BUNDLER_VERSION=2.2.15 +ARG YARN_VERSION=1.22.19 # Copy Installers RUN mkdir -p /docker-files @@ -37,22 +17,18 @@ RUN chmod +x /docker-files/*.sh RUN /docker-files/deps.sh # Install PostgreSQL -# RUN /docker-files/pg.sh - -RUN apt-get install -y postgresql-client +RUN /docker-files/pg.sh # Install NodeJS, Yarn RUN /docker-files/node.sh -# install build dependencies -RUN apt-get update -y && apt-get install -y build-essential git \ - && apt-get clean && rm -f /var/lib/apt/lists/*_* - -# prepare build dir -WORKDIR /app +# Configure bundler ENV LANG=C.UTF-8 BUNDLE_JOBS=4 BUNDLE_RETRY=3 +# Uncomment this line if you want to run binstubs without prefixing with `bin/` or `bundle exec` +# ENV PATH=/app/bin:$BUNDLE_BIN:$PATH + # Upgrade RubyGems and install required Bundler version RUN gem update --system && \ gem install bundler:$BUNDLER_VERSION @@ -67,24 +43,16 @@ RUN adduser --disabled-password --gecos "" docker && adduser docker staff RUN mkdir /usr/src/app RUN chown -R docker:docker /usr/src/app - -# set build ENV -ENV RAILS_ENV="prod" -ENV DEFAULT_LOCALE $DEFAULT_LOCALE - - -# install mix dependencies -COPY mix.exs mix.lock ./ -RUN mix deps.get --only $MIX_ENV -RUN mkdir config - -# copy compile-time config files before we compile dependencies -# to ensure any relevant config change will trigger the dependencies -# to be re-compiled. # Bundler install gems WORKDIR /tmp COPY Gemfile Gemfile.lock /tmp/ +# RUN bundle config set force_ruby_platform true RUN bundle install -j ${BUNDLE_JOBS} --retry ${BUNDLE_RETRY} + +COPY --from=mwader/static-ffmpeg:4.1.4-2 /ffmpeg /ffprobe /usr/local/bin/ + +COPY --from=realies/audiowaveform /usr/local/bin/audiowaveform /usr/local/bin/ + # Clean up APT when done RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ truncate -s 0 /var/log/*log @@ -99,56 +67,17 @@ WORKDIR /usr/src/app # Copy app source into container COPY --chown=docker:docker . /usr/src/app/ +RUN yarn --version -RUN echo yarn -v - -RUN npm install +RUN yarn install # Precompile assets - production only # Clean up temp files and Yarn cache folder RUN NODE_OPTIONS="--max-old-space-size=2048" \ RAILS_ENV=${APP_ENV} \ + DB_ADAPTER=nulldb \ SECRET_KEY_BASE=`bin/rake secret` \ bundle exec rails assets:precompile --trace \ - && rm -rf /usr/src/app/node_modules /usr/src/app/tmp/cache/* /tmp/* \ - && yarn cache clean - -# start a new build stage so that the final image will only contain -# the compiled release and other runtime necessities -FROM ${RUNNER_IMAGE} - - -RUN apt-get update -y && apt-get install -y libstdc++6 openssl \ - libncurses5 locales \ - imagemagick - -COPY --from=mwader/static-ffmpeg:4.1.4-2 /ffmpeg /ffprobe /usr/local/bin/ - -# Audiowaveform -RUN apt install software-properties-common -y && \ - apt-get update && \ - add-apt-repository ppa:chris-needham/ppa && \ - apt-get update && \ - apt-get install audiowaveform -y - -RUN apt-get clean && rm -f /var/lib/apt/lists/*_* - -# Set the locale -RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen - -ENV LANG "en_US.UTF-8" -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -#WORKDIR "/app" -#RUN chown nobody /app - -# set runner ENV -# ENV MIX_ENV="prod" - -# Only copy the final release from the build stage -# COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/rauversion ./ - -#USER nobody + && echo "done!" -#CMD ["/app/bin/server"] \ No newline at end of file +# yarn cache clean diff --git a/app/services/peaks_generator.rb b/app/services/peaks_generator.rb index c700e8c..ae8751d 100644 --- a/app/services/peaks_generator.rb +++ b/app/services/peaks_generator.rb @@ -6,7 +6,7 @@ def initialize(file, duration = 20) end def run - case true # Rails.application.config.peaks_processor + case ENV['PEAKS_PROCESSOR'] when "audiowaveform" run_audiowaveform else