Commit graph

10 commits

Author SHA1 Message Date
Josh Klar
e4d33b316c
devxp: Base the application container images off new Ruby base image. (#19633)
This "rebases" our application images off of the new Ruby base image
added in #19632, and fixes numerous problems and quirks with how the
images were built along the way. Notably:

- Issues where layers attempted to delete files in prior layers have
  been resolved (this caused build failures on some Docker filesystem
  drivers, notably overlay2).

- Bundler is no longer allowed to deviate from or modify the lockfile
  (`BUNDLE_FROZEN` is now `true`).

- `git(1)` is no longer required to live inside the container and `.git`
  is no longer required to be copied into the Docker build context, as
  these were only used to calculate `FOREM_BUILD_SHA`, which is now
  passed in as a Build Argument to the container build context.

- The entire source tree is no longer `chmod` in one giant swing, which
  ran so long on my system (as just one example) that I gave up after
  15-20 minutes and issued it a `SIGTERM`. Instead, `COPY --chown` is
  used more heavily and ensures the `APP_USER` will have access to the
  requisite files.

This new container image appears to build successfully for
`linux/arm64`, which refs (but does not complete) #19626. Currently,
such builds aren't automated , and must be built on a developer
workstation. For example:

```sh
docker buildx build --platform linux/amd64,linux/arm64 -f Containerfile . -t ghcr.io/forem/forem:klardotsh-test --push --build-arg VCS_REF=$(git rev-parse --short HEAD)
```

In the meantime, the existing `linux/amd64`-only BuildKite scripts have
been updated to allow this PR to merge as a separate unit, and CI
refactors to enable the multiarch builds of `linux/arm64,linux/amd64`
can come later when more time is available.

This is one of several blockers on the path to getting #19603 merged.
The next step in that chronology will be rebasing that work on top of
this work, which *should* be, on the containerization side, as
straightforward as bumping `Containerfile.base` to reference the new
upstream image, rebuilding the base container, and then bumping the
reference in `Containerfile`.
2023-06-29 10:50:26 -07:00
Jamie Gaskins
9eb5658489
Fix Buildkite builds for versioning (#15510)
We don't need it to be "version tag is set OR not empty", we need both
to be true.
2021-11-29 11:08:10 -05:00
Daniel Uber
ccbac93ea5
Only print BUILDKITE environment variables when they were present (#14487)
* Only print BUILDKITE environment variables when they were present

This was causing errors running the build_containers.sh script
locally, since only buildkite was passing these (and errors stop the
script, so nothing was built).

* Simplify conditional guards to check only for BUILDKITE variable

https://buildkite.com/docs/pipelines/environment-variables#bk-env-vars-buildkite
describes the simplest "this is buildkite" check, BUILDKITE is always
true when running in buildkite.
2021-08-19 11:42:42 -05:00
Jamie Gaskins
de852bd466
Separate -v and -z into two separate commands (#14420) 2021-08-05 11:02:39 -04:00
Jamie Gaskins
f0edbcef90
Add support for versioned releases (#13750)
* Add release scripts

* Use `delete` over `gsub` with an empty string

Co-authored-by: Michael Kohl <citizen428@dev.to>

* wip

* wip

* Include stable release-channel branches in builds

* Add changelog stub

* Include the union of changes to the changelog

* Add things

* Add stuff

* Remove test changelog content

* Fix String#delete call

Extraneous `.` made Ruby parse it as a range

* Fix suggested release command

* Use backticks to denote a command to run

* Add debugging output to script

* Build more appropriate containers for stable

This includes tags

* Check if branch *starts with* release channel name

* Cache tag builds from production tag

* Skip trying to build containers for untagged pushes

* Clear out stubbed changelog

* Update PR template to incorporate CHANGELOG.md

* Run Rubocop on release scripts

This excludes some linter rules that only make sense in code that is
running as part of the Rails app. For example, we can't rely on
`ActiveSupport::TimeWithZone` because these scripts don't load Rails,
and we define top-level methods because they're scripts rather than
complex applications.

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-07-28 10:10:33 -04:00
Joe Doss
5fcb5cd2d9
Expire the SHA tag after 2 months. (#14058)
* Expire the SHA tag after 2 months.

* Add --tag
2021-07-02 16:03:06 -05:00
Mac Siri
7ba3c3a81c
Add container tag expiration (#14040) 2021-06-21 19:41:10 -04:00
Joe Doss
d7144ce787
Fix bundle issues and a few other things. (#11528)
* Fix bundle issues with the Multistage container
and adjusts a few other things:

- Disable ruby docs on bundler gem install
- Fix the bundle config
- chmod +x on scripts/build_containers.sh

* Add app/assets back into the builder image.

* Looks like running:

yarn install --frozen-lockfile \
&& RAILS_ENV=test NODE_ENV=test bundle exec rails webpacker:compile'

is super busted.

https://buildkite.com/forem/build-containers/builds/48#97451356-6552-40a1-8333-ac6fc0fccc3a

so let's just comment that out for now.
2020-11-21 17:25:09 -06:00
Joe Doss
b485ef2eb9
Jdoss/more buildkite container fixes (#11503)
* Fix bug on creating the testing container for PRs and create a function to
run docker image prune -f that will get run when the script exits cleanly or
uncleanly. This prevent junk containers from building up over time.

* Add in some labels and keys. Add in building containers on master branch.

* Let's also build on main branch for when we eventually move away from master.

* Let's use a previous builder image as a cache as it might speed things up.
2020-11-19 13:34:20 -06:00
Joe Doss
1d4685219d
Multistage container builds (#11468)
* WIP multi-stage container build.

* Move to a multistage build process in the Containerfile.

* Enable testing container

* Finalize the multistage build script and Containerfile. Ooof!

I got blocked for a bit with this bugger:

Step 27/32 : COPY --from=builder --chown=${APP_USER}:${APP_USER} ${APP_HOME} ${APP_HOME}
failed to copy files: failed to copy directory: Error processing tar file(exit status 1): Container ID 100999 cannot be mapped to a host ID

but https://github.com/phusion/passenger-docker/issues/235#issuecomment-636318827

was a good shove in the right direction!

* Fix bugs on container build script.

* Adjust compose files to use multistage builds.

* Add in Buildkite pipeline for building containers.

* Update CODEOWNERS to claim ownership over things that Systems Eng cares about
2020-11-19 10:03:35 -06:00