Skip to content

Commit

Permalink
#369 Code fix (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj authored Mar 6, 2025
1 parent 4437c6c commit 1f87283
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 64 deletions.
145 changes: 82 additions & 63 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,43 @@ USER root
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update \
&& apt-get -y install \
gcc \
make \
pkg-config \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*
&& apt-get -y install \
gcc \
make \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-venv \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*

# Work around until Debian repos catch up to modern versions of fio.

RUN mkdir /tmp/fio \
&& cd /tmp/fio \
&& wget https://github.com/axboe/fio/archive/refs/tags/fio-3.30.zip \
&& unzip fio-3.30.zip \
&& cd fio-fio-3.30/ \
&& ./configure \
&& make \
&& make install \
&& fio --version \
&& cd \
&& rm -rf /tmp/fio
&& cd /tmp/fio \
&& wget https://github.com/axboe/fio/archive/refs/tags/fio-3.30.zip \
&& unzip fio-3.30.zip \
&& cd fio-fio-3.30/ \
&& ./configure \
&& make \
&& make install \
&& fio --version \
&& cd \
&& rm -rf /tmp/fio

# Create and activate virtual environment.

RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"

# pip install Python dependencies.

COPY requirements.txt .
RUN pip3 install --upgrade pip \
&& pip3 install -r requirements.txt \
&& rm /requirements.txt

# -----------------------------------------------------------------------------
# Stage: Final
Expand All @@ -58,8 +74,8 @@ ARG IMAGE_MAINTAINER
ARG IMAGE_VERSION

LABEL Name=${IMAGE_NAME} \
Maintainer=${IMAGE_MAINTAINER} \
Version=${IMAGE_VERSION}
Maintainer=${IMAGE_MAINTAINER} \
Version=${IMAGE_VERSION}

# Define health check.

Expand All @@ -74,55 +90,58 @@ USER root
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update \
&& apt-get -y install \
elvis-tiny \
htop \
iotop \
jq \
net-tools \
openssh-server \
postgresql-common \
procps \
python3-dev \
python3-pip \
python3-pyodbc \
strace \
tree \
unzip \
wget \
zip \
&& /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
&& apt-get -y install postgresql-client-14 \
&& rm -rf /var/lib/apt/lists/*

# Install packages via pip.

COPY requirements.txt .
RUN pip3 install --upgrade pip \
&& pip3 install -r requirements.txt \
&& rm /requirements.txt
&& apt-get -y install \
elvis-tiny \
htop \
iotop \
jq \
net-tools \
openssh-server \
postgresql-common \
procps \
python3-dev \
python3-pip \
python3-pyodbc \
strace \
tree \
unzip \
wget \
zip \
&& /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
&& apt-get -y install postgresql-client-14 \
&& rm -rf /var/lib/apt/lists/*

# Copy python virtual environment from the builder image.

COPY --from=builder /app/venv /app/venv

# Activate virtual environment.

ENV VIRTUAL_ENV=/app/venv
ENV PATH="/app/venv/bin:${PATH}"

# Configure sshd.

RUN mkdir /var/run/sshd \
&& sed -i -e '$aPermitRootLogin yes' /etc/ssh/sshd_config \
&& sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
&& echo "export LANGUAGE=C" >> /etc/profile \
&& echo "export LC_ALL=C.UTF-8" >> /etc/profile \
&& echo "export LD_LIBRARY_PATH=/opt/senzing/g2/lib" >> /etc/profile \
&& echo "export PATH=${PATH}" >> /etc/profile \
&& echo "export PYTHONPATH=/opt/senzing/g2/python:/opt/senzing/g2/sdk/python" >> /etc/profile \
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile \
&& echo "export NOTVISIBLE='in users profile'" >> /etc/profile \
&& echo "export ROOT_PASSWORD=senzingsshdpassword" >> /etc/profile \
&& echo "export SENZING_DOCKER_LAUNCHED=true" >> /etc/profile \
&& echo "export SENZING_SKIP_DATABASE_PERFORMANCE_TEST=true" >> /etc/profile \
&& echo "export SENZING_SSHD_SHOW_PERFORMANCE_WARNING=true" >> /etc/profile \
&& echo "export VISIBLE=now" >> /etc/profile
&& sed -i -e '$aPermitRootLogin yes' /etc/ssh/sshd_config \
&& sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
&& echo "export LANGUAGE=C" >> /etc/profile \
&& echo "export LC_ALL=C.UTF-8" >> /etc/profile \
&& echo "export LD_LIBRARY_PATH=/opt/senzing/g2/lib" >> /etc/profile \
&& echo "export PATH=${PATH}" >> /etc/profile \
&& echo "export PYTHONPATH=/opt/senzing/g2/python:/opt/senzing/g2/sdk/python" >> /etc/profile \
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile \
&& echo "export NOTVISIBLE='in users profile'" >> /etc/profile \
&& echo "export ROOT_PASSWORD=senzingsshdpassword" >> /etc/profile \
&& echo "export SENZING_DOCKER_LAUNCHED=true" >> /etc/profile \
&& echo "export SENZING_SKIP_DATABASE_PERFORMANCE_TEST=true" >> /etc/profile \
&& echo "export SENZING_SSHD_SHOW_PERFORMANCE_WARNING=true" >> /etc/profile \
&& echo "export VISIBLE=now" >> /etc/profile

# Copy files from repository.

COPY ./rootfs /
RUN /app/update-motd.sh

# Copy files from prior stages.

Expand All @@ -135,9 +154,9 @@ EXPOSE 22
# Runtime environment variables.

ENV NOTVISIBLE="in users profile" \
ROOT_PASSWORD=senzingsshdpassword \
SENZING_ETC_PATH=/etc/opt/senzing \
SENZING_SSHD_SHOW_PERFORMANCE_WARNING=true
ROOT_PASSWORD=senzingsshdpassword \
SENZING_ETC_PATH=/etc/opt/senzing \
SENZING_SSHD_SHOW_PERFORMANCE_WARNING=true

# Runtime execution.

Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ see [Environment Variables](https://github.com/senzing-garage/knowledge-base/blo
1. Set these environment variable values:

```console
export GIT_ACCOUNT=senzing
export GIT_ACCOUNT=senzing-garage
export GIT_REPOSITORY=docker-sshd
export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git
export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
Expand Down
13 changes: 13 additions & 0 deletions rootfs/app/update-motd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

SIGNAL_V3=/opt/senzing/g2/g2BuildVersion.json
SIGNAL_V4=/opt/senzing/er/szBuildVersion.json

if test -f ${SIGNAL_V3}; then
cp /etc/motd.v3 /etc/motd
exit 0
fi

# Default Message Of The Day.

cp /etc/motd.v4 /etc/motd
File renamed without changes.
6 changes: 6 additions & 0 deletions rootfs/etc/motd.v4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
************** Senzing Diagnostics Container **************
!!THIS IS NOT INTENDED FOR sz_file_loader!!

This container is designed for debugging and basic tasks.
To load data, use the stream-loader or REST API server.
***********************************************************

0 comments on commit 1f87283

Please sign in to comment.