diff --git a/Dockerfile b/Dockerfile index 562235dac2..f002a92a84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ -FROM centos:7 +FROM centos:8 LABEL maintainer="tdockendorf@osc.edu; johrstrom@osc.edu" +ARG VERSION=latest +ARG CONCURRENCY=4 + # setup the ondemand repositories -RUN yum -y install https://yum.osc.edu/ondemand/latest/ondemand-release-web-latest-1-6.noarch.rpm +RUN dnf -y install https://yum.osc.edu/ondemand/latest/ondemand-release-web-latest-1-6.noarch.rpm # install all the dependencies -RUN yum install -y centos-release-scl && \ - yum -y update && \ - yum install -y \ +RUN dnf -y update && \ + dnf install -y \ file \ lsof \ sudo \ @@ -15,15 +17,17 @@ RUN yum install -y centos-release-scl && \ gcc-c++ \ git \ patch \ + ondemand-gems \ ondemand-runtime \ ondemand-build \ ondemand-apache \ ondemand-ruby \ ondemand-nodejs \ + ondemand-python \ + ondemand-dex \ ondemand-passenger \ - ondemand-nginx \ - ondemand-dex && \ - yum clean all && rm -rf /var/cache/yum/* + ondemand-nginx && \ + dnf clean all && rm -rf /var/cache/dnf/* RUN mkdir -p /opt/ood RUN mkdir -p /var/www/ood/{apps,public,discover} @@ -31,17 +35,17 @@ RUN mkdir -p /var/www/ood/apps/{sys,dev,usr} COPY docker/launch-ood /opt/ood/launch COPY mod_ood_proxy /opt/ood/mod_ood_proxy -COPY nginx_stage/ /opt/ood/nginx_stage +COPY nginx_stage /opt/ood/nginx_stage COPY ood-portal-generator /opt/ood/ood-portal-generator COPY ood_auth_map /opt/ood/ood_auth_map COPY apps /opt/ood/apps COPY Rakefile /opt/ood/Rakefile COPY lib /opt/ood/lib -RUN cd /opt/ood && \ - scl enable ondemand -- rake -mj4 build && \ +RUN source /opt/rh/ondemand/enable && \ + rake -f /opt/ood/Rakefile -mj$CONCURRENCY build && \ mv /opt/ood/apps/* /var/www/ood/apps/sys/ && \ - rm -rf /opt/ood/Rakefile /opt/ood/apps + rm -rf /opt/ood/Rakefile /opt/ood/apps /opt/ood/lib # copy configuration files RUN mkdir -p /etc/ood/config @@ -51,7 +55,6 @@ RUN sed -i -r \ -e 's/^#listen_addr_port:.*/listen_addr_port: 8080/g' \ -e 's/^#port:.*/port: 8080/g' \ -e 's/^#servername:.*/servername: localhost/g' \ - -e "s/^#lua_log_level:.*/lua_log_level: 'debug'/g" \ /etc/ood/config/ood_portal.yml # make some misc directories & files @@ -66,9 +69,10 @@ apache ALL=(ALL) NOPASSWD: /opt/ood/nginx_stage/sbin/nginx_stage' >/etc/sudoers. # run the OOD executables to setup the env RUN /opt/ood/ood-portal-generator/sbin/update_ood_portal RUN /opt/ood/nginx_stage/sbin/update_nginx_stage -RUN sed -i 's#HTTPD24_HTTPD_SCLS_ENABLED=.*#HTTPD24_HTTPD_SCLS_ENABLED="httpd24 ondemand"#g' /opt/rh/httpd24/service-environment -RUN groupadd ood -RUN useradd --create-home --gid ood ood +RUN echo $VERSION > /opt/ood/VERSION +# this one bc centos:8 doesn't generate localhost cert +RUN /usr/libexec/httpd-ssl-gencerts EXPOSE 8080 +EXPOSE 5556 CMD [ "/opt/ood/launch" ] diff --git a/lib/tasks/container_files/Dockerfile.test b/Dockerfile.test similarity index 100% rename from lib/tasks/container_files/Dockerfile.test rename to Dockerfile.test diff --git a/lib/tasks/container_files/Dockerfile.base b/lib/tasks/container_files/Dockerfile.base deleted file mode 100644 index f002a92a84..0000000000 --- a/lib/tasks/container_files/Dockerfile.base +++ /dev/null @@ -1,78 +0,0 @@ -FROM centos:8 -LABEL maintainer="tdockendorf@osc.edu; johrstrom@osc.edu" - -ARG VERSION=latest -ARG CONCURRENCY=4 - -# setup the ondemand repositories -RUN dnf -y install https://yum.osc.edu/ondemand/latest/ondemand-release-web-latest-1-6.noarch.rpm - -# install all the dependencies -RUN dnf -y update && \ - dnf install -y \ - file \ - lsof \ - sudo \ - gcc \ - gcc-c++ \ - git \ - patch \ - ondemand-gems \ - ondemand-runtime \ - ondemand-build \ - ondemand-apache \ - ondemand-ruby \ - ondemand-nodejs \ - ondemand-python \ - ondemand-dex \ - ondemand-passenger \ - ondemand-nginx && \ - dnf clean all && rm -rf /var/cache/dnf/* - -RUN mkdir -p /opt/ood -RUN mkdir -p /var/www/ood/{apps,public,discover} -RUN mkdir -p /var/www/ood/apps/{sys,dev,usr} - -COPY docker/launch-ood /opt/ood/launch -COPY mod_ood_proxy /opt/ood/mod_ood_proxy -COPY nginx_stage /opt/ood/nginx_stage -COPY ood-portal-generator /opt/ood/ood-portal-generator -COPY ood_auth_map /opt/ood/ood_auth_map -COPY apps /opt/ood/apps -COPY Rakefile /opt/ood/Rakefile -COPY lib /opt/ood/lib - -RUN source /opt/rh/ondemand/enable && \ - rake -f /opt/ood/Rakefile -mj$CONCURRENCY build && \ - mv /opt/ood/apps/* /var/www/ood/apps/sys/ && \ - rm -rf /opt/ood/Rakefile /opt/ood/apps /opt/ood/lib - -# copy configuration files -RUN mkdir -p /etc/ood/config -RUN cp /opt/ood/nginx_stage/share/nginx_stage_example.yml /etc/ood/config/nginx_stage.yml -RUN cp /opt/ood/ood-portal-generator/share/ood_portal_example.yml /etc/ood/config/ood_portal.yml -RUN sed -i -r \ - -e 's/^#listen_addr_port:.*/listen_addr_port: 8080/g' \ - -e 's/^#port:.*/port: 8080/g' \ - -e 's/^#servername:.*/servername: localhost/g' \ - /etc/ood/config/ood_portal.yml - -# make some misc directories & files -RUN mkdir -p /var/lib/ondemand-nginx/config/apps/{sys,dev,usr} -RUN touch /var/lib/ondemand-nginx/config/apps/sys/{dashboard,shell,files,file-editor,activejobs,myjobs}.conf - -# setup sudoers for apache -RUN echo -e 'Defaults:apache !requiretty, !authenticate \n\ -Defaults:apache env_keep += "NGINX_STAGE_* OOD_*" \n\ -apache ALL=(ALL) NOPASSWD: /opt/ood/nginx_stage/sbin/nginx_stage' >/etc/sudoers.d/ood - -# run the OOD executables to setup the env -RUN /opt/ood/ood-portal-generator/sbin/update_ood_portal -RUN /opt/ood/nginx_stage/sbin/update_nginx_stage -RUN echo $VERSION > /opt/ood/VERSION -# this one bc centos:8 doesn't generate localhost cert -RUN /usr/libexec/httpd-ssl-gencerts - -EXPOSE 8080 -EXPOSE 5556 -CMD [ "/opt/ood/launch" ] diff --git a/lib/tasks/docker.rb b/lib/tasks/docker.rb index dd0b4ad810..9c7029c15b 100644 --- a/lib/tasks/docker.rb +++ b/lib/tasks/docker.rb @@ -1,25 +1,27 @@ -DOCKER_NAME = ENV["DOCKER_NAME"] || "ondemand-dev" -DOCKER_PORT = ENV["DOCKER_PORT"] || '8080' +DOCKER_NAME = ENV["DOCKER_NAME"] || "ondemand-dev" namespace :docker do desc "Build Docker container" - task :build do - sh "docker build -t #{DOCKER_NAME} ." + task :build => ["package:latest_container"] do + file = "Dockerfile.test" + build_cmd = podman_runtime? ? buildah_build_cmd(file, DOCKER_NAME) : docker_build_cmd(file, DOCKER_NAME) + sh build_cmd unless image_exists?("#{DOCKER_NAME}:#{image_tag}") + sh tag_latest_container_cmd(DOCKER_NAME) end desc "Run Docker container" task :run do - sh "docker run -p #{DOCKER_PORT}:8080 -p 5556:5556 -v '#{PROJ_DIR}:/ondemand' --name #{DOCKER_NAME} --rm --detach #{DOCKER_NAME}" + sh "#{container_runtime} run -p 8080:8080 -p 5556:5556 -v '#{PROJ_DIR}:/ondemand' --name #{DOCKER_NAME} --rm --detach #{DOCKER_NAME}:latest" end desc "Kill Docker container" task :kill do - sh "docker kill #{DOCKER_NAME}" + sh "#{container_runtime} kill #{DOCKER_NAME}" end desc "Connect to Docker container" task :connect do - sh "docker exec -it #{DOCKER_NAME} /bin/bash" + sh "#{container_runtime} exec -it #{DOCKER_NAME} /bin/bash" end desc "Use docker to do development, build run and connect to container" diff --git a/lib/tasks/packaging.rb b/lib/tasks/packaging.rb index d6ab109e49..05074f7aca 100644 --- a/lib/tasks/packaging.rb +++ b/lib/tasks/packaging.rb @@ -48,7 +48,7 @@ def tag_latest_container_cmd(image_name) end task container: [:clean] do - file = "lib/tasks/container_files/Dockerfile.base" + file = "Dockerfile" cmd = podman_runtime? ? buildah_build_cmd(file, image_name) : docker_build_cmd(file, image_name) sh cmd unless image_exists?("ood:#{image_tag}") end @@ -58,7 +58,7 @@ def tag_latest_container_cmd(image_name) end task test_container: [:latest_container] do - file = "lib/tasks/container_files/Dockerfile.test" + file = "Dockerfile.test" build_cmd = podman_runtime? ? buildah_build_cmd(file, test_image_name) : docker_build_cmd(file, test_image_name) sh build_cmd unless image_exists?("#{test_image_name}:#{image_tag}") sh tag_latest_container_cmd(test_image_name)