Skip to content

Commit

Permalink
Nightly dev container (#2041)
Browse files Browse the repository at this point in the history
Build dev containers from nightly rpms instead of from source reducing their image size and utilizing systemd within the container to test it.

Co-authored-by: treydock <[email protected]>
  • Loading branch information
johrstrom and treydock authored May 23, 2022
1 parent eaf9bc1 commit f86e410
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 81 deletions.
26 changes: 20 additions & 6 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
FROM ood:latest
FROM rockylinux/rockylinux:8
LABEL maintainer="[email protected]; [email protected]"

ARG USER=ood
ARG UID=1000
ARG GID=1000

RUN dnf reinstall -y httpd-tools && \
dnf install -y \
strace lua python3 && \
RUN dnf install -y https://yum.osc.edu/ondemand/latest/ondemand-release-web-latest-1-6.noarch.rpm && \
dnf clean all && rm -rf /var/cache/dnf/*

RUN cp /etc/yum.repos.d/ondemand-web.repo /etc/yum.repos.d/ondemand-nightly-web.repo && \
sed /etc/yum.repos.d/ondemand-web.repo -e 's/latest/nightly/g' \
-e 's/ondemand-web/ondemand-web-nightly/g' > /etc/yum.repos.d/ondemand-nightly-web.repo

RUN dnf -y update && \
dnf install -y dnf-utils && \
dnf config-manager --set-enabled powertools && \
dnf -y module enable nodejs:14 ruby:2.7 && \
dnf install -y ondemand ondemand-dex && \
dnf clean all && rm -rf /var/cache/dnf/*

RUN sed -i 's#^CREATE_MAIL_SPOOL=yes#CREATE_MAIL_SPOOL=no#' /etc/default/useradd; \
grep $GID /etc/group >/dev/null || groupadd -g $GID $USER; \
useradd -l -u $UID --create-home --gid $GID $USER && \
echo "$USER ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/$USER

COPY docker/dev-entrypoint.sh /entrypoint.sh
RUN sed -i 's|--rpm|--rpm -f --insecure|g' /etc/systemd/system/httpd.service.d/ood-portal.conf
RUN systemctl enable httpd ondemand-dex

CMD [ "/sbin/init" ]

CMD [ "/entrypoint.sh" ]
EXPOSE 8080
EXPOSE 5556
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require "#{TASK_DIR}/build"
require "#{TASK_DIR}/packaging"
require "#{TASK_DIR}/test"
require "#{TASK_DIR}/lint"
require "#{TASK_DIR}/docker"
require "#{TASK_DIR}/development"
require "#{TASK_DIR}/install"

Expand Down
27 changes: 0 additions & 27 deletions docker/dev-entrypoint.sh

This file was deleted.

5 changes: 1 addition & 4 deletions lib/tasks/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,11 @@ def container_rt_args
end

def docker_rt_args
[
'--user', "#{user.uid}:#{user.gid}"
].freeze
[ '--tmpfs', '/run', '-v', '/sys/fs/cgroup:/sys/fs/cgroup:ro'].freeze
end

def podman_rt_args
[
'--userns', 'keep-id',
'--security-opt', 'label=disable'
].tap do |arr|
arr.concat [ '--cap-add', 'sys_ptrace'] unless additional_caps.include?('--privileged')
Expand Down
28 changes: 0 additions & 28 deletions lib/tasks/docker.rb

This file was deleted.

14 changes: 4 additions & 10 deletions lib/tasks/packaging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@
sh tag_latest_container_cmd(image_names[:ood])
end

desc "Build container with Dockerfile.test"
task test_container: [:latest_container] do
sh build_cmd("Dockerfile.test", test_image_name) unless image_exists?("#{test_image_name}:#{ood_image_tag}")
sh tag_latest_container_cmd(test_image_name)
end

desc "Build container with Dockerfile.dev"
task dev_container: [:latest_container] do
task :dev_container do
extra = ["--build-arg", "USER=#{user.name}"]
extra.concat ["--build-arg", "UID=#{user.uid}"]
extra.concat ["--build-arg", "GID=#{user.gid}"]

sh build_cmd("Dockerfile.dev", dev_image_name, extra_args: extra) unless image_exists?("#{dev_image_name}:#{ood_image_tag}")
sh tag_latest_container_cmd(dev_image_name)
image_name = dev_image_name
sh build_cmd("Dockerfile.dev", image_name, image_tag: today, extra_args: extra) unless image_exists?("#{dev_image_name}:#{today}")
sh tag_latest_container_cmd(dev_image_name, image_tag: today)
end

begin
Expand Down
9 changes: 4 additions & 5 deletions lib/tasks/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ def nightly_version
"#{version_major}.#{version_minor}.#{date}-#{id}.#{git_hash}.nightly"
end

def today
Time.now.strftime("%Y%m%d")
end

def numeric_tag
@numeric_tag ||= git_tag.delete_prefix('v')
end
Expand All @@ -175,10 +179,6 @@ def container_runtime
podman_runtime? ? "podman" : "docker"
end

def test_image_name
"ood-test"
end

def dev_image_name
"ood-dev"
end
Expand All @@ -195,7 +195,6 @@ def image_names
@image_names ||=
{
ood: "ood",
test: "ood-test",
dev: "ood-dev"
}.freeze
end
Expand Down

0 comments on commit f86e410

Please sign in to comment.