Skip to content

Commit

Permalink
Update base Dockerfile with previous Dockerfile.base
Browse files Browse the repository at this point in the history
Move Dockerfile.test to root of repo
Update docker namespace tasks to utilize docker functions and latest Dockerfile
  • Loading branch information
treydock committed Dec 24, 2020
1 parent 8107471 commit 6fd2e6a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 103 deletions.
36 changes: 20 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
FROM centos:7
FROM centos:8
LABEL maintainer="[email protected]; [email protected]"

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 \
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 \
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}
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
Expand All @@ -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
Expand All @@ -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" ]
File renamed without changes.
78 changes: 0 additions & 78 deletions lib/tasks/container_files/Dockerfile.base

This file was deleted.

16 changes: 9 additions & 7 deletions lib/tasks/docker.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/packaging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 6fd2e6a

Please sign in to comment.