Skip to content
Snippets Groups Projects
Commit e70511b7 authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added base image with Ubuntu 22.04 and renamed the previous one to let them...

Added base image with Ubuntu 22.04 and renamed the previous one to let them co-exist. Update some software versions.
parent fe2ae1cb
No related branches found
No related tags found
No related merge requests found
Showing
with 464 additions and 2 deletions
...@@ -31,7 +31,8 @@ fi ...@@ -31,7 +31,8 @@ fi
if [[ "x$SERVICE" == "x" ]] ; then if [[ "x$SERVICE" == "x" ]] ; then
# Build all services # Build all services
NOCACHE=$NOCACHE rosetta/build base NOCACHE=$NOCACHE rosetta/build base_ubuntu18.04
NOCACHE=$NOCACHE rosetta/build base_ubuntu22.04
NOCACHE=$NOCACHE rosetta/build slurmbase NOCACHE=$NOCACHE rosetta/build slurmbase
NOCACHE=$NOCACHE rosetta/build slurmcluster NOCACHE=$NOCACHE rosetta/build slurmcluster
NOCACHE=$NOCACHE rosetta/build slurmclustermaster NOCACHE=$NOCACHE rosetta/build slurmclustermaster
......
File moved
File moved
File moved
FROM ubuntu:22.04
MAINTAINER Stefano Alberto Russo <stefano.russo@gmail.com>
#----------------------
# Basics
#----------------------
# Set non-interactive
ENV DEBIAN_FRONTEND noninteractive
# Update
RUN apt-get update
# Utilities
RUN apt-get install -y nano telnet unzip wget supervisor openssh-server
# Devel
RUN apt-get install -y build-essential python3-dev git-core
# Java
RUN apt-get install -y openjdk-8-jre
# IP utilities (mandatory for DNS!)
RUN apt-get install net-tools iproute2 iputils-ping -y
#------------------------
# Rosetta user
#------------------------
# Add group. We chose GID 65527 to try avoiding conflicts.
RUN groupadd -g 65527 rosetta
# Add user. We chose UID 65527 to try avoiding conflicts.
RUN useradd rosetta -d /rosetta -u 65527 -g 65527 -m -s /bin/bash
# Add rosetta user to sudoers
RUN adduser rosetta sudo
# Keys
RUN mkdir /rosetta/.ssh
COPY keys/authorized_keys /rosetta/.ssh/
COPY keys/id_rsa /rosetta/.ssh/
RUN chmod 0600 /rosetta/.ssh/id_rsa
COPY keys/id_rsa.pub /rosetta/.ssh/
RUN chown -R rosetta:rosetta /rosetta/.ssh
# Install suodo
RUN apt-get install sudo -y
# No pass sudo (for everyone, actually)
COPY sudoers /etc/sudoers
# bash_profile for loading correct env (/env.sh created by entrypoint.sh)
RUN echo "source /env.sh" > /rosetta/.bash_profile
#------------------------
# Data, Logs and opt dirs
#------------------------
# Create dirs
RUN mkdir /data && mkdir /var/log/rosetta
# Give right permissions
RUN chown -R rosetta:rosetta /data && chown -R rosetta:rosetta /var/log/rosetta
#----------------------
# Supervisord conf
#----------------------
COPY supervisord.conf /etc/supervisor/
#----------------------
# SSH conf
#----------------------
RUN mkdir /var/run/sshd && chmod 0755 /var/run/sshd
COPY supervisord_sshd.conf /etc/supervisor/conf.d/
#----------------------
# Prestartup scripts
#----------------------
# Create dir for prestartup scripts and copy main script
RUN mkdir /prestartup
COPY prestartup.py /
#----------------------
# Entrypoint
#----------------------
# Copy entrypoint
COPY entrypoint.sh /
# Give right permissions
RUN chmod 755 /entrypoint.sh
# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash
# Exit on any error. More complex thing could be done in future
# (see https://stackoverflow.com/questions/4381618/exit-a-script-on-error)
set -e
echo ""
echo "[INFO] Executing entrypoint..."
#---------------------
# Persistency
#---------------------
echo "[INFO] Handling safe persistency"
if [ "x$SAFE_PERSISTENCY" == "xTrue" ]; then
echo "[INFO] Safe persistency set"
if [ ! -f /safe_persistent/persistent.img ]; then
truncate -s 10G /safe_persistent/persistent.img
mkfs.ext4 -F /safe_persistent/persistent.img
fi
mkdir /persistent
mount -oloop /safe_persistent/persistent.img /persistent
fi
echo "[INFO] Handling persistency"
# If persistent data:
if [ "x$PERSISTENT_DATA" == "xTrue" ]; then
echo "[INFO] Persistent data set"
if [ ! -f /persistent/data/.persistent_initialized ]; then
mv /data /persistent/data
ln -s /persistent/data /data
touch /data/.persistent_initialized
else
mkdir -p /trash
mv /data /trash
ln -s /persistent/data /data
fi
fi
# If persistent log:
if [ "x$PERSISTENT_LOG" == "xTrue" ]; then
echo "[INFO] Persistent log set"
if [ ! -f /persistent/log/.persistent_initialized ]; then
mv /var/log /persistent/log
ln -s /persistent/log /var/log
touch /var/log/.persistent_initialized
else
mkdir -p /trash
mv /var/log /trash
ln -s /persistent/log /var/log
fi
fi
# If persistent home:
if [ "x$PERSISTENT_HOME" == "xTrue" ]; then
echo "[INFO] Persistent home set"
if [ ! -f /persistent/home/.persistent_initialized ]; then
mv /home /persistent/home
ln -s /persistent/home /home
touch /home/.persistent_initialized
else
mkdir -p /trash
mv /home /trash
ln -s /persistent/home /home
fi
fi
# If persistent opt:
if [ "x$PERSISTENT_OPT" == "xTrue" ]; then
echo "[INFO] Persistent opt set"
if [ ! -f /persistent/opt/.persistent_initialized ]; then
mv /opt /persistent/opt
ln -s /persistent/opt /opt
touch /opt/.persistent_initialized
else
mkdir -p /trash
mv /opt /trash
ln -s /persistent/opt /opt
fi
fi
#---------------------
# Prestartup scripts
#---------------------
if [ "x$SAFEMODE" == "xFalse" ]; then
echo "[INFO] Executing prestartup scripts (parents + current):"
python3 /prestartup.py
else
echo "[INFO] Not executing prestartup scripts as we are in safemode"
fi
#---------------------
# Save env
#---------------------
echo "[INFO] Dumping env"
# Save env vars for later usage (e.g. ssh)
env | \
while read env_var; do
if [[ $env_var == HOME\=* ]]; then
: # Skip HOME var
elif [[ $env_var == PWD\=* ]]; then
: # Skip PWD var
else
echo "export $env_var" >> /env.sh
fi
done
#---------------------
# Entrypoint command
#---------------------
# Start!
if [[ "x$@" == "x" ]] ; then
ENTRYPOINT_COMMAND="supervisord"
else
ENTRYPOINT_COMMAND=$@
fi
echo -n "[INFO] Executing Docker entrypoint command: "
echo $ENTRYPOINT_COMMAND
exec "$ENTRYPOINT_COMMAND"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC2n4wiLiRmE1sla5+w0IW3wwPW/mqhhkm7IyCBS+rGTgnts7xsWcxobvamNdD6KSLNnjFZbBb7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ifRIVqhT6tZCPOU4fdOvJKCRjKrf7gcW/E33ovZFgoOCJ2vBLIh9N9ME0v7tG15JpRtgIBsCXwLcl3tVyCZJ/eyYMbc3QJGsbcPGb2CYRjDbevPCQlNavcMdlyrNIke7VimM5aW8OBJKVh5wCNRpd9XylrKo1cZHYxu/c5Lr6VUZjLpxDlSz+IuTn4VE7vmgHNPnXdlxRKjLHG/FZrZTSCWFEBcRoSa/hysLSFwwDjKd9nelOZRNBvJ+NY48vA8ixVnk4WAMlR/5qhjTRam66BVysHeRcbjJ2IGjwTJC5Q== rosetta@rosetta.platform
import os
import sys
import datetime
import subprocess
from collections import namedtuple
def shell(command, interactive=False):
'''Execute a command in the shell. By default prints everything. If the capture switch is set,
then it returns a namedtuple with stdout, stderr, and exit code.'''
if interactive:
exit_code = subprocess.call(command, shell=True)
if exit_code == 0:
return True
else:
return False
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(stdout, stderr) = process.communicate()
exit_code = process.wait()
# Convert to str (Python 3)
stdout = stdout.decode(encoding='UTF-8')
stderr = stderr.decode(encoding='UTF-8')
# Output namedtuple
Output = namedtuple('Output', 'stdout stderr exit_code')
# Return
return Output(stdout, stderr, exit_code)
prestartup_scripts_path='/prestartup'
def sorted_ls(path):
mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime
file_list = list(sorted(os.listdir(path), key=mtime))
return file_list
for item in sorted_ls(prestartup_scripts_path):
if item.endswith('.sh'):
# Execute this startup script
print('[INFO] Executing prestartup script "{}"...'.format(item))
script = prestartup_scripts_path+'/'+item
# Use bash and not chmod + execute, see https://github.com/moby/moby/issues/9547
out = shell('bash {}'.format(script))
# Set date
date_str = str(datetime.datetime.now()).split('.')[0]
# Print and log stdout and stderr
for line in out.stdout.strip().split('\n'):
print(' out: {}'.format(line))
for line in out.stderr.strip().split('\n'):
print(' err: {}'.format(line))
# Handle error in the startup script
if out.exit_code:
print('[ERROR] Exit code "{}" for "{}"'.format(out.exit_code, item))
# Exit with error code 1
sys.exit(1)
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
nodaemon=true ; Mandatory to run Supervisor in foreground and avoid Docker to exit!
; The below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
[program:sshd]
; Process definition
process_name = sshd
command = /usr/sbin/sshd -D
autostart = true
autorestart = true
startsecs = 5
stopwaitsecs = 10
; Log files
stdout_logfile = /var/log/supervisor/%(program_name)s_out.log
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 5
stderr_logfile = /var/log/supervisor/%(program_name)s_err.log
stderr_logfile_maxbytes = 10MB
stderr_logfile_backups = 5
FROM rosetta/base FROM rosetta/base_ubuntu18.04
MAINTAINER Stefano Alberto Russo <stefano.russo@gmail.com> MAINTAINER Stefano Alberto Russo <stefano.russo@gmail.com>
# Always start with an apt-get update when extending Reyns images, # Always start with an apt-get update when extending Reyns images,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment