Skip to content

Commit

Permalink
fix #845 and cleanup
Browse files Browse the repository at this point in the history
There were more issues with the alpine nginx images than I first realised.

This patch:
- Moves nginx/conf.d to nginx/http.d because that is how the directory
  is now called within images
- Fixes the nginx/start script to work with /etc/nginx/http.d instead of
  the deprecated and missing /etc/nginx/conf.d
- Fixes alpine-based Dockerfiles to copy config files from/to the correct
  locations
- Fixes amazonlinux-based Dockerfiles to also store config in
  /etc/nginx/http.d so nginx/start works as expeted
- Harmonized files in dockerfiles/v1/. Lots of changes in the
  past were not ported to all of these files. They should only differ
  in the base image used (alpine/amazonlinux) and the bbb-playback target.
  Base image versions or other details should be the same.
  • Loading branch information
defnull committed Nov 28, 2022
1 parent b1ea9ca commit 76481a5
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/conf.d /etc/nginx/http.d/
COPY nginx/http.d /etc/nginx/http.d/
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
Expand Down
36 changes: 24 additions & 12 deletions dockerfiles/v1/bionic230-alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.13 AS alpine
FROM alpine:3.15 AS alpine

FROM ubuntu:18.04 AS bbb-playback
ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -24,34 +24,46 @@ FROM alpine AS nginx
RUN apk add --no-cache nginx tini gettext \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN rm /etc/nginx/conf.d/default.conf
RUN rm /etc/nginx/http.d/default.conf
COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/conf.d /etc/nginx/http.d/
# This will be needed with alpine 3.14 since conf.d is being phased out.
# RUN ln -s /etc/nginx/http.d/ /etc/nginx/conf.d
COPY nginx/http.d /etc/nginx/http.d/
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
CMD [ "/etc/nginx/start", "-g", "daemon off;" ]

FROM alpine AS base
RUN apk add --no-cache \
libpq
RUN apk add --no-cache \
libpq \
libxml2 \
libxslt \
ruby \
ruby-irb \
ruby-bigdecimal \
ruby-bundler \
ruby-json \
tini \
tzdata \
shared-mime-info
# ruby-start.
# Install Ruby from sources since Scalelite does not use the version shipped with Apline.
ARG RUBY_RELEASE="https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz"
ARG RUBY="ruby-2.7.6"
RUN apk add --no-cache git make gcc g++ libc-dev pkgconfig \
libxml2-dev libxslt-dev postgresql-dev coreutils curl wget bash \
gnupg tar linux-headers bison readline-dev readline zlib-dev \
zlib yaml-dev autoconf ncurses-dev curl-dev apache2-dev \
libx11-dev libffi-dev tcl-dev tk-dev
RUN wget --no-verbose -O ruby.tar.gz ${RUBY_RELEASE} && \
tar -xf ruby.tar.gz && \
cd /${RUBY} && \
ac_cv_func_isnan=yes ac_cv_func_isinf=yes \
./configure --disable-install-doc && \
make && \
make test && \
make install
RUN cd / && \
rm ruby.tar.gz && \
rm -rf ${RUBY_NAME}
# ruby-end.
RUN addgroup scalelite --gid 1000 && \
adduser -u 1000 -h /srv/scalelite -G scalelite -D scalelite
RUN addgroup scalelite-spool --gid 2000 && \
Expand Down
27 changes: 17 additions & 10 deletions dockerfiles/v1/bionic230-amazonlinux
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazonlinux:2.0.20211201.0 AS amazonlinux
FROM amazonlinux:2.0.20221004.0 AS amazonlinux

FROM ubuntu:18.04 AS bbb-playback
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -30,15 +30,18 @@ RUN chmod +x /sbin/tini
RUN yum -y install redhat-rpm-config

FROM amazonlinux-base AS nginx
RUN yes | amazon-linux-extras install nginx1
RUN yum -y install gettext
COPY nginx/nginx.repo /etc/yum.repos.d/nginx.repo
RUN yum install yum-utils -y
RUN yum install nginx -y
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log
COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/conf.d /etc/nginx/conf.d/
COPY nginx/http.d /etc/nginx/http.d/
RUN rm -r /etc/nginx/conf.d; ln -s /etc/nginx/http.d/ /etc/nginx/conf.d
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
Expand All @@ -51,24 +54,28 @@ RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash -
RUN yum -y install nodejs
# Install Ruby & Rails
RUN curl -sL -o /etc/yum.repos.d/yarn.repo https://dl.yarnpkg.com/rpm/yarn.repo
RUN amazon-linux-extras enable ruby2.6 \
&& yum -y install git tar gzip yarn shared-mime-info libxslt zlib-devel sqlite-devel mariadb-devel postgresql-devel ruby-devel rubygems-devel rubygem-bundler rubygem-io-console rubygem-irb rubygem-json rubygem-minitest rubygem-net-http-persistent rubygem-net-telnet rubygem-power_assert rubygem-rake rubygem-test-unit rubygem-thor rubygem-xmlrpc rubygem-bigdecimal
RUN amazon-linux-extras enable ruby2.6 postgresql14 \
&& yum -y install git tar gzip yarn shared-mime-info libxslt zlib-devel sqlite-devel mariadb-devel libpq-devel ruby-devel rubygems-devel rubygem-bundler rubygem-io-console rubygem-irb rubygem-json rubygem-minitest rubygem-power_assert rubygem-rake rubygem-test-unit rubygem-bigdecimal
RUN yum -y install python3 python3-pip shadow-utils
RUN gem install bundler -v '2.1.4'
RUN groupadd scalelite --gid 1000 && \
useradd -u 1000 -d /srv/scalelite -g scalelite scalelite
RUN groupadd scalelite-spool --gid 2000 && \
usermod -a -G scalelite-spool scalelite
WORKDIR /srv/scalelite

FROM base as builder
RUN rm -rf nginx
USER scalelite:scalelite
COPY --chown=scalelite:scalelite Gemfile* ./
RUN bundle config build.nokogiri --use-system-libraries \
&& bundle install --deployment --without development:test -j4 \
&& rm -rf vendor/bundle/ruby/*/cache \
&& find vendor/bundle/ruby/*/gems/ \( -name '*.c' -o -name '*.o' \) -delete
RUN bundle --version
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle config set --local deployment 'true'
RUN bundle config set --local without 'development:test'
RUN bundle install -j4
RUN rm -rf vendor/bundle/ruby/*/cache
RUN find vendor/bundle/ruby/*/gems/ \( -name '*.c' -o -name '*.o' \) -delete
COPY --chown=scalelite:scalelite . ./
RUN rm -rf nginx

FROM base AS application
USER scalelite:scalelite
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/v1/bionic240-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/conf.d /etc/nginx/http.d/
COPY nginx/http.d /etc/nginx/http.d/
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
Expand Down
3 changes: 2 additions & 1 deletion dockerfiles/v1/bionic240-amazonlinux
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/conf.d /etc/nginx/conf.d/
COPY nginx/http.d /etc/nginx/http.d/
RUN rm -r /etc/nginx/conf.d; ln -s /etc/nginx/http.d/ /etc/nginx/conf.d
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
Expand Down
36 changes: 27 additions & 9 deletions dockerfiles/v1/xenial220-alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.11 AS alpine
FROM alpine:3.15 AS alpine

FROM ubuntu:16.04 AS bbb-playback
ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -17,13 +17,15 @@ RUN apt-get update \
&& dpkg -i --force-depends *.deb

FROM alpine AS nginx
RUN apk add --no-cache nginx=1.16.1-r6 tini gettext \
RUN apk add --no-cache nginx tini gettext \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN rm /etc/nginx/conf.d/default.conf
RUN rm /etc/nginx/http.d/default.conf
COPY --from=bbb-playback /etc/bigbluebutton/nginx /etc/bigbluebutton/nginx/
COPY --from=bbb-playback /var/bigbluebutton/playback /var/bigbluebutton/playback/
COPY nginx /etc/nginx/
COPY nginx/start /etc/nginx/start
COPY nginx/dhparam.pem /etc/nginx/dhparam.pem
COPY nginx/http.d /etc/nginx/http.d/
EXPOSE 80
EXPOSE 443
ENV NGINX_HOSTNAME=localhost
Expand All @@ -34,14 +36,30 @@ RUN apk add --no-cache \
libpq \
libxml2 \
libxslt \
ruby \
ruby-irb \
ruby-bigdecimal \
ruby-bundler \
ruby-json \
tini \
tzdata \
shared-mime-info
# ruby-start.
# Install Ruby from sources since Scalelite does not use the version shipped with Apline.
ARG RUBY_RELEASE="https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz"
ARG RUBY="ruby-2.7.6"
RUN apk add --no-cache git make gcc g++ libc-dev pkgconfig \
libxml2-dev libxslt-dev postgresql-dev coreutils curl wget bash \
gnupg tar linux-headers bison readline-dev readline zlib-dev \
zlib yaml-dev autoconf ncurses-dev curl-dev apache2-dev \
libx11-dev libffi-dev tcl-dev tk-dev
RUN wget --no-verbose -O ruby.tar.gz ${RUBY_RELEASE} && \
tar -xf ruby.tar.gz && \
cd /${RUBY} && \
ac_cv_func_isnan=yes ac_cv_func_isinf=yes \
./configure --disable-install-doc && \
make && \
make test && \
make install
RUN cd / && \
rm ruby.tar.gz && \
rm -rf ${RUBY_NAME}
# ruby-end.
RUN addgroup scalelite --gid 1000 && \
adduser -u 1000 -h /srv/scalelite -G scalelite -D scalelite
RUN addgroup scalelite-spool --gid 2000 && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ server {
proxy_http_version 1.1;
}

include conf.d/scalelite/*;
include conf.d/scalelite.common;
include http.d/scalelite/*;
include http.d/scalelite.common;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ server {
proxy_http_version 1.1;
}

include conf.d/scalelite/*;
include conf.d/scalelite.common;
include http.d/scalelite/*;
include http.d/scalelite.common;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ server {
proxy_http_version 1.1;
}

include conf.d/scalelite/*;
include conf.d/scalelite.common;
include http.d/scalelite/*;
include http.d/scalelite.common;
}
10 changes: 5 additions & 5 deletions nginx/start
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ fi
echo "Generating templated nginx configuration..."
if [ "$NGINX_RECORDINGS_ONLY" = "true" ] ; then
echo "Using nginx recordings only configuration template."
nginx_template=/etc/nginx/conf.d/scalelite-recordings-only.template
nginx_template=/etc/nginx/http.d/scalelite-recordings-only.template
elif [ "$NGINX_BEHIND_PROXY" = "true" ] ; then
echo "Using proxy configuration template."
nginx_template=/etc/nginx/conf.d/scalelite-proxy.template
nginx_template=/etc/nginx/http.d/scalelite-proxy.template
elif [ "$NGINX_SSL" = "true" ] ; then
echo "Using SSL configuration template."
nginx_template=/etc/nginx/conf.d/scalelite-ssl.template
nginx_template=/etc/nginx/http.d/scalelite-ssl.template
else
echo "Using non-SSL configuration template."
nginx_template=/etc/nginx/conf.d/scalelite.template
nginx_template=/etc/nginx/http.d/scalelite.template
fi

# apply SCALELITE_API port from environment variable or use default port 3000
SCALELITE_API_PORT=${SCALELITE_API_PORT:-3000}
export SCALELITE_API_PORT

envsubst '$SCALELITE_API_PORT $URL_HOST' <$nginx_template >/etc/nginx/conf.d/scalelite.conf
envsubst '$SCALELITE_API_PORT $URL_HOST' <$nginx_template >/etc/nginx/http.d/scalelite.conf
unset nginx_template

mkdir -p /run/nginx
Expand Down

0 comments on commit 76481a5

Please sign in to comment.