drop ruby image

refs DE-187

Caching intermittently fails due to the intermediate layer in the multi-stage build. We don’t have any consumers of this image for now, so let’s work around this problem by removing it, until we can prioritize investigating why the multi-stage build isn’t using the cache for the intermediate layer.

[change-merged]
[build-registry-path=jenkins/canvas-lms/de-187-drop-ruby-layer]

Test Plan:
1. Cache is used on a build with a file changed on a separate node.

Change-Id: I8d771ac532bcd0bacc554f02f6b129294bcfedf9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244848
QA-Review: Aaron Ogata <aogata@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Butters <jbutters@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
Aaron Ogata 2020-08-12 08:26:37 -07:00
parent aeb5a289fc
commit f17f6bb59f
4 changed files with 24 additions and 82 deletions

View File

@ -4,11 +4,12 @@
ARG RUBY=2.6
FROM instructure/passenger-nginx-alpine:${RUBY} AS ruby-gems-only
FROM instructure/passenger-nginx-alpine:${RUBY} AS dependencies
LABEL maintainer="Instructure"
ARG POSTGRES_CLIENT=12.2
ARG ALPINE_MIRROR=http://dl-cdn.alpinelinux.org/alpine
ARG NODE=10.19.0-r0
ENV APP_HOME /usr/src/app/
ENV RAILS_ENV production
@ -96,16 +97,6 @@ RUN set -eux; \
&& bundle install --jobs $(nproc) \
&& rm -rf $GEM_HOME/cache
FROM ruby-gems-only AS ruby-final
COPY --chown=docker:docker . $APP_HOME
FROM ruby-gems-only AS yarn-only
LABEL maintainer="Instructure"
# default alpine HTTPS mirror
ARG ALPINE_MIRROR=https://alpine.global.ssl.fastly.net/alpine/
ARG NODE=10.19.0-r0
USER root
RUN set -eux; \
\
@ -178,7 +169,7 @@ RUN set -eux; \
&& (yarn install --pure-lockfile || yarn install --pure-lockfile --network-concurrency 1) \
&& yarn cache clean
FROM yarn-only AS webpack-final
FROM dependencies AS webpack-final
ARG JS_BUILD_NO_UGLIFY=0
COPY --chown=docker:docker . ${APP_HOME}

37
Jenkinsfile vendored
View File

@ -172,17 +172,10 @@ pipeline {
ALPINE_MIRROR = configuration.alpineMirror()
NODE = configuration.node()
RUBY = configuration.ruby() // RUBY_VERSION is a reserved keyword for ruby installs
RUBY_IMAGE = "$BUILD_IMAGE-ruby"
RUBY_MERGE_IMAGE = "$RUBY_IMAGE:$GERRIT_BRANCH"
RUBY_PATCHSET_IMAGE = "$RUBY_IMAGE:$NAME-$TAG_SUFFIX"
RUBY_GEMS_IMAGE = "$BUILD_IMAGE-ruby-gems-only"
RUBY_GEMS_MERGE_IMAGE = "$RUBY_GEMS_IMAGE:$GERRIT_BRANCH"
RUBY_GEMS_PATCHSET_IMAGE = "$RUBY_GEMS_IMAGE:$NAME-$TAG_SUFFIX"
YARN_IMAGE = "$BUILD_IMAGE-yarn-only"
YARN_MERGE_IMAGE = "$YARN_IMAGE:$GERRIT_BRANCH"
YARN_PATCHSET_IMAGE = "$YARN_IMAGE:$NAME-$TAG_SUFFIX"
DEPENDENCIES_IMAGE = "$BUILD_IMAGE-dependencies"
DEPENDENCIES_MERGE_IMAGE = "$DEPENDENCIES_IMAGE:$GERRIT_BRANCH"
DEPENDENCIES_PATCHSET_IMAGE = "$DEPENDENCIES_IMAGE:$NAME-$TAG_SUFFIX"
CASSANDRA_IMAGE_TAG=imageTag.cassandra()
DYNAMODB_IMAGE_TAG=imageTag.dynamodb()
@ -296,9 +289,7 @@ pipeline {
]) {
sh 'build/new-jenkins/docker-build.sh'
}
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $RUBY_GEMS_PATCHSET_IMAGE"
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $RUBY_PATCHSET_IMAGE"
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $YARN_PATCHSET_IMAGE"
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $DEPENDENCIES_PATCHSET_IMAGE"
}
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $PATCHSET_TAG"
if (isPatchsetPublishable()) {
@ -432,16 +423,8 @@ pipeline {
// Retriggers won't have an image to tag/push, pull that
// image if doesn't exist. If image is not found it will
// return NULL
if (!sh (script: 'docker images -q $RUBY_GEMS_PATCHSET_IMAGE')) {
sh './build/new-jenkins/docker-with-flakey-network-protection.sh pull $RUBY_GEMS_PATCHSET_IMAGE'
}
if (!sh (script: 'docker images -q $RUBY_PATCHSET_IMAGE')) {
sh './build/new-jenkins/docker-with-flakey-network-protection.sh pull $RUBY_PATCHSET_IMAGE'
}
if (!sh (script: 'docker images -q $YARN_PATCHSET_IMAGE')) {
sh './build/new-jenkins/docker-with-flakey-network-protection.sh pull $YARN_PATCHSET_IMAGE'
if (!sh (script: 'docker images -q $DEPENDENCIES_PATCHSET_IMAGE')) {
sh './build/new-jenkins/docker-with-flakey-network-protection.sh pull $DEPENDENCIES_PATCHSET_IMAGE'
}
if (!sh (script: 'docker images -q $PATCHSET_TAG')) {
@ -450,14 +433,10 @@ pipeline {
// publish canvas-lms:$GERRIT_BRANCH (i.e. canvas-lms:master)
sh 'docker tag $PUBLISHABLE_TAG $MERGE_TAG'
sh 'docker tag $RUBY_GEMS_PATCHSET_IMAGE $RUBY_GEMS_MERGE_IMAGE'
sh 'docker tag $RUBY_PATCHSET_IMAGE $RUBY_MERGE_IMAGE'
sh 'docker tag $YARN_PATCHSET_IMAGE $YARN_MERGE_IMAGE'
sh 'docker tag $DEPENDENCIES_PATCHSET_IMAGE $DEPENDENCIES_MERGE_IMAGE'
// push *all* canvas-lms images (i.e. all canvas-lms prefixed tags)
sh './build/new-jenkins/docker-with-flakey-network-protection.sh push $MERGE_TAG'
sh './build/new-jenkins/docker-with-flakey-network-protection.sh push $RUBY_GEMS_MERGE_IMAGE'
sh './build/new-jenkins/docker-with-flakey-network-protection.sh push $RUBY_MERGE_IMAGE'
sh './build/new-jenkins/docker-with-flakey-network-protection.sh push $YARN_MERGE_IMAGE'
sh './build/new-jenkins/docker-with-flakey-network-protection.sh push $DEPENDENCIES_MERGE_IMAGE'
}
}
}

View File

@ -1,11 +1,12 @@
<%= generation_message %>
ARG RUBY=2.6
FROM instructure/passenger-nginx-alpine:${RUBY} AS ruby-gems-only
FROM instructure/passenger-nginx-alpine:${RUBY} AS dependencies
LABEL maintainer="Instructure"
ARG POSTGRES_CLIENT=12.2
ARG ALPINE_MIRROR=http://dl-cdn.alpinelinux.org/alpine
ARG NODE=10.19.0-r0
ENV APP_HOME /usr/src/app/
ENV RAILS_ENV production
@ -93,16 +94,6 @@ RUN set -eux; \
&& bundle install --jobs $(nproc) \
&& rm -rf $GEM_HOME/cache
FROM ruby-gems-only AS ruby-final
COPY --chown=docker:docker . $APP_HOME
FROM ruby-gems-only AS yarn-only
LABEL maintainer="Instructure"
# default alpine HTTPS mirror
ARG ALPINE_MIRROR=https://alpine.global.ssl.fastly.net/alpine/
ARG NODE=10.19.0-r0
USER root
RUN set -eux; \
\
@ -139,10 +130,12 @@ RUN set -eux; \
&& (yarn install --pure-lockfile || yarn install --pure-lockfile --network-concurrency 1) \
&& yarn cache clean
FROM yarn-only AS webpack-final
FROM dependencies AS webpack-final
ARG JS_BUILD_NO_UGLIFY=0
COPY --chown=docker:docker . ${APP_HOME}
RUN set -exu; \
\
COMPILE_ASSETS_NPM_INSTALL=0 bundle exec rails canvas:compile_assets \
COMPILE_ASSETS_NPM_INSTALL=0 JS_BUILD_NO_UGLIFY="$JS_BUILD_NO_UGLIFY" bundle exec rails canvas:compile_assets \
&& yarn cache clean

View File

@ -6,51 +6,30 @@ WORKSPACE=${WORKSPACE:-$(pwd)}
RUBY_PATCHSET_IMAGE=${RUBY_PATCHSET_IMAGE:-canvas-lms-ruby}
PATCHSET_TAG=${PATCHSET_TAG:-canvas-lms}
commonRubyArgs=(
dependencyArgs=(
--build-arg ALPINE_MIRROR="$ALPINE_MIRROR"
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg NODE="$NODE"
--build-arg POSTGRES_CLIENT="$POSTGRES_CLIENT"
--build-arg RUBY="$RUBY"
--file Dockerfile
)
commonNodeArgs=(
--build-arg NODE="$NODE"
)
if [[ "${SKIP_CACHE:-false}" = "false" ]]; then
commonRubyArgs+=("--cache-from $RUBY_GEMS_MERGE_IMAGE")
commonNodeArgs+=("--cache-from $YARN_MERGE_IMAGE")
dependencyArgs+=("--cache-from $DEPENDENCIES_MERGE_IMAGE")
fi
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
--pull \
${commonRubyArgs[@]} \
--tag "$RUBY_GEMS_PATCHSET_IMAGE" \
--target ruby-gems-only \
${dependencyArgs[@]} \
--tag "$DEPENDENCIES_PATCHSET_IMAGE" \
--target dependencies \
"$WORKSPACE"
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
--pull \
${commonRubyArgs[@]} \
--tag "$RUBY_PATCHSET_IMAGE" \
--target ruby-final \
"$WORKSPACE"
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
${commonRubyArgs[@]} \
${commonNodeArgs[@]} \
--tag "$YARN_PATCHSET_IMAGE" \
--target yarn-only \
"$WORKSPACE"
# shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
${commonRubyArgs[@]} \
${commonNodeArgs[@]} \
${dependencyArgs[@]} \
--build-arg JS_BUILD_NO_UGLIFY="$JS_BUILD_NO_UGLIFY" \
--tag "$PATCHSET_TAG" \
--target webpack-final \