* 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>
* Fix a few bugs with the create_buildkite_pr_build.sh script.
This will ${PULL_REQUEST_ID:-} will allow for PULL_REQUEST_ID to be not set in
the if statement so the script won't fail.
It fixes the jq lookups on GITHUB_EVENT_PATH for setting:
PULL_REQUEST_ID
COMMENT_USER_LOGIN
COMMENT_URL
from GITHUB_EVENT_PATH
It fixes the jq lookups on
* Add in missing dub quotes
* Remove rebase workflow as it will not work as expected with third party forks.
* Add the create_buildkite_pr_build.sh script.
This script will use the GitHub API to gather information about the PR, the PR
Author and create a Pull Request pipeline build on Buildkite.
You can mock out the things needed to work on this script locally with the
following environment variables exported:
export BUILDKITE_API_ACCESS_TOKEN=notarealtoken
export GITHUB_EVENT_PATH=$(curl --silent 2d0e0bdefc/github_actions_event_context.json)
export GITHUB_REPOSITORY=forem/forem
export GITHUB_TOKEN=notarealtoken
Note: You will need to get your own BUILDKITE_API_ACCESS_TOKEN and GITHUB_TOKEN
tokens.
You can then run the script locally to create builds from a pull request. The
GITHUB_EVENT_PATH JSON data is from https://github.com/forem/forem/pull/1181
which might not build on Buildkite down the road if is is closed. You might need
to pull down that JSON data and find and replace the PR number 11818 with thing
else.
Also this script could be busted out into it's own GitHub Action repo so you can
work on it outside of the Forem repo, but I don't have the mental fortitude to
work on GitHub Actions at this time. It is the most painful CI systems I have used
to date in terms of having an very very poor feedback loop/developer experience.
It desperately needs a REPL or mock shell for you to develop actions in so you don't
have to keep submitting PRs to your main branch to see results.
* Use premade development image.
* Use prebuilt container for podman-compose too!
* Fix bundle bundle_finished path.
* Fix docker-compose to work with the Multistage Containerfile
Add root user for Forem containers, fix bundle_finished path and make
webpacker wait for the bundle to finish.
Switch Redis to redis:6.0.9-alpine
* Remove build steps and fix bundle path.
* Merge dev entrypoint into the main one.
* Use merged entrypoint.sh, remove old entrypoint directives, and fix a dockerize bug.
* Make sure unset BUNDLE_WITHOUT and remove without in bundle config.
* Unset BUNDLE_WITHOUT="development:test" as a global ENV.
Also ensure that we remove the without directives for development and testing.
This will make sure that the right gems are installed for each environment.
Removed some unneeded COPYs and remove a commented out RUN.
* Fix ENTRYPOINT on development and testing containers.
* Fix entrypoint and command on rails container.
* Ignore bundle_finished file.
* Fix REDIS_ env vars and adjust podman-compose file.
* Change bundle_finished path and update Yarn docker-compose command.
* 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.
* 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.
* 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
* Create entrypoint-dev.sh to be used with devel workflows with docker/podman compose
and adjust the compose files to use it.
* Adjust the entrypoint script so we have better control over when we run
rake assets:precompile and rake app_initializer:setup.
* Copy vendor/cache so we can bundle install from cached gems instead of
fetching them from the Internet.
* Run rake assets:precompile in the container build.
* Add in clobber and clean tasks to entrypoint.
In the past it was always useful to have meta data within regards to the SHA and
build date/time. This adds in two new env vars that are written to disk as flat
files and then exported to environment variables when the container starts up.
This motivation comes from this comment:
https://github.com/forem/forem/pull/9987#discussion_r476123829
RELEASE_FOOTPRINT will be set to the output of date -u +'%Y-%m-%dT%H:%M:%SZ'
(2020-08-25T02:02:21Z for example) which will fix https://github.com/forem/forem/pull/9904
This will be reset to a new date and time string every time the container starts.
* 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
* chore: updates to sync your forked ranch
* chore: use rease instead
* feat: update the script to not bomb out if you have added the remote before
* chore: add the comment back
* Add script to clean / reset the fork and start from upstream
* Add script to sync fork with latest changes from upstream
* Remove swap file accidentially checked in
* Add exit on break to shell scripts and documentation of shell scripts to workflow-suggested workflow
Co-authored-by: Mac Siri <krairit.siri@gmail.com>