* Move from Alpine Linux to Fedora Linux. This changes the base container image away from Alpine Linux to Fedora Linux to address some musl libc issues with some of our gems. It also moved the main file to a Containerfile and symlinks the Dockerfile to it. This makes our container setup less Docker-centric as Linux users most likely will be using Podman as their container runtime. Lastly, it moves the WORKDIR from /usr/src/app to /opt/apps/devto. The Linux FHS states that /opt is the spot for Optional application software packages and /usr/src is for kernel source code. https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard /opt Optional application software packages /usr/src Source code, e.g., the kernel source code with its header files. Also, if SELinux becomes a thing in our future, moving this makes it easier to manage contexts out of /opt rather than /usr/src. * Adjust the Containerfile a bit to add some missing packages, make it more generic and move env vars to the docker-compose. * Move the Dockerfile to a symlink to the Containerfile. We need to be able to support more than just Docker for a container runtime. Moving everything to a Containerfile and symlinking the Dockerfile helps users run runtimes such as Podman. * Add in new entrypoint files and fix the app path in docker-entrypoint.sh * Refactor the docker-compose.yml file so it doesn't build the main application container three times in a row. We can use the same container for web, webpacker, and sidekiq. Also make the volume names very explicit on what their contents and add in SELinux context support with :Z * Fix ELASTICSEARCH_URL. * Remove the absolute path on ip binary and add in iproute to Containerfile. * Symlink the Dockerfile to Containerfile and add in a container-compose.yml file for usage with podman-compose. We are waiting for this issue to get resolved https://github.com/containers/libpod/issues/6153 and for podman-compose to mature a bit more. A user using podman-compose can use podman-compose -f container-compose.yml to launch the DEV container stack with Podman. * Update the .gitignore file to reflect the new container volumes. * Fix the entrypoint script on the Containerfile and clean up a bunch of things. * Rework the Containerfile to prep it to run as a non-root user. We have to wait for this issue to get fixed: https://github.com/containers/libpod/issues/6153 for Linux users and then we can uncomment the USER line so we are running Rails as a non-root user. :toot: * This reworks the compose files so each task that is needed to start the app has a correct wait command with dockerize. It also adds in containers for doing yarn and bundle things for development. Since we mount the code directory inside the container we lose our pre-containerized gems and node_modules. This means users can run: Linux podman-compose -f container-compose.yml up Mac docker-compose up and it should correctly build the app stack with containers! * Clean up old container related things. * Add in some container pre-reqs and my name to the "Core team" section! :toot: * Adjust the seed and sidekiq compose entries so they do not use the web entrypoint and set the REDIS_URL and REDIS_SESSIONS_URL env vars for seed. Add in some echos to the entrypoint.sh. Also set docker-compose to use :delegated on mount points to speed things up. https://docs.docker.com/storage/bind-mounts/#configure-mount-consistency-for-macos * Just call yarn install --dev on the yarn container. * Update documentation to support Docker and Podman as Container Engines and move the page from docker to containers to reflect the fact not all users run their containers via Docker. There are dozens of us... DOZENS! * Set --local on bundle config so it just impacts this Ruby app. * Renamed bin/docker-setup to bin/container-setup to reflect the fact that that we can use Podman as a container engine. I also refactored it so it does some basic pre-flight checks for docker and docker-compose or podman and podman-compose to make sure users have a container engine installed. * Set cache_all_platforms true for bundler. * Bump docker-compose dockerize -timeout to 45min for slower macOS hardware. * Move to the consolidated app_initializer:setup rake task for bootstrapping the app. * Update docs/installation/readme.md
52 lines
1.9 KiB
Docker
52 lines
1.9 KiB
Docker
FROM quay.io/devto/ruby:2.7.1
|
|
|
|
USER root
|
|
|
|
RUN curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo && \
|
|
dnf install -y bash git ImageMagick iproute less libcurl libcurl-devel \
|
|
libffi-devel libxml2-devel libxslt-devel nodejs pcre-devel \
|
|
postgresql postgresql-devel ruby-devel tzdata yarn
|
|
|
|
ENV APP_USER=devto
|
|
ENV APP_UID=1000
|
|
ENV APP_GID=1000
|
|
ENV APP_HOME=/opt/apps/devto/
|
|
RUN mkdir -p ${APP_HOME} && chown "${APP_UID}":"${APP_GID}" "${APP_HOME}"
|
|
RUN groupadd -g "${APP_GID}" "${APP_USER}" && \
|
|
adduser -u "${APP_UID}" -g "${APP_GID}" -d "${APP_HOME}" "${APP_USER}"
|
|
|
|
ENV BUNDLER_VERSION=2.1.4
|
|
RUN gem install bundler:"${BUNDLER_VERSION}"
|
|
ENV GEM_HOME=/opt/apps/bundle/
|
|
ENV BUNDLE_SILENCE_ROOT_WARNING=1 BUNDLE_APP_CONFIG="${GEM_HOME}"
|
|
ENV PATH "${GEM_HOME}"/bin:$PATH
|
|
RUN mkdir -p "${GEM_HOME}" && chown "${APP_UID}":"${APP_GID}" "${GEM_HOME}"
|
|
|
|
ENV DOCKERIZE_VERSION=v0.6.1
|
|
RUN wget https://github.com/jwilder/dockerize/releases/download/"${DOCKERIZE_VERSION}"/dockerize-linux-amd64-"${DOCKERIZE_VERSION}".tar.gz \
|
|
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-"${DOCKERIZE_VERSION}".tar.gz \
|
|
&& rm dockerize-linux-amd64-"${DOCKERIZE_VERSION}".tar.gz
|
|
|
|
WORKDIR "${APP_HOME}"
|
|
|
|
# As soon as this:
|
|
# https://github.com/containers/libpod/issues/6153
|
|
# issue is fixed for Linux users we can uncomment the line below so we are not
|
|
# running the app as the root user. :toot:
|
|
# USER "${APP_USER}"
|
|
|
|
COPY ./.ruby-version "${APP_HOME}"
|
|
COPY ./Gemfile ./Gemfile.lock "${APP_HOME}"
|
|
RUN bundle check || bundle install --jobs 20 --retry 5
|
|
|
|
COPY ./package.json ./yarn.lock ./.yarnrc "${APP_HOME}"
|
|
COPY ./.yarn "${APP_HOME}"/.yarn
|
|
RUN yarn install
|
|
|
|
RUN mkdir -p "${APP_HOME}"/public/{uploads,images,podcasts}
|
|
|
|
COPY . "${APP_HOME}"
|
|
|
|
ENTRYPOINT ["./scripts/entrypoint.sh"]
|
|
|
|
CMD ["bundle", "exec", "rails","server","-b","0.0.0.0","-p","3000"]
|