From 96730afd6c67468ca824e4501283972473d8845a Mon Sep 17 00:00:00 2001 From: rachejazz Date: Wed, 10 Jul 2024 15:30:18 +0100 Subject: [PATCH 1/3] WIP docker migration Signed-off-by: rachejazz --- Dockerfile | 30 ++++++++++++++++++++++++++++++ bin/build.sh | 5 +++++ 2 files changed, 35 insertions(+) create mode 100644 Dockerfile create mode 100644 bin/build.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5238416 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:22.04 + +RUN apt-get -y update && \ + apt-get install -y sudo python3 python3-pip \ + gcc git python3-dev libssl-dev libffi-dev cron \ + python3-lxml apache2 libapache2-mod-wsgi-py3 \ + mariadb-server python3-pymysql + +RUN sudo pip3 install cffi cryptography Flask \ + launchpadlib simplejson requests pytest \ + python-dotenv + +ADD --keep-git-dir=true https://github.com/openmainframeproject/software-discovery-tool.git /opt/software-discovery-tool + +WORKDIR /opt/software-discovery-tool + +RUN git submodule update --init --recursive --remote + +RUN cp src/config/supported_distros.py.example src/config/supported_distros.py + +RUN bash -c "echo 'export PYTHONPATH=/opt/software-discovery-tool/src/classes:/opt/software-discovery-tool/src/config:$PYTHONPATH' > /etc/profile.d/software-discovery-tool.sh" + +RUN cp -f /opt/software-discovery-tool/src/config/sdt.conf /etc/apache2/sites-available/sdt.conf && \ + mv /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/z-000-default.conf + +RUN useradd apache && \ + chown -R apache:apache /opt/software-discovery-tool/ + +RUN apachectl restart +USER apache diff --git a/bin/build.sh b/bin/build.sh new file mode 100644 index 0000000..2d750ba --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,5 @@ +# check if every .example is renamed to original +# check if root password in env file has changed or not +# print if there are previous images in the system for sdt +# add instruction how to remove them +# docker build and run From c523da63b4c0ae211cd1b2fcbc44f0844e059800 Mon Sep 17 00:00:00 2001 From: rachejazz Date: Thu, 11 Jul 2024 01:47:38 +0100 Subject: [PATCH 2/3] WIP docker migration Signed-off-by: rachejazz --- Dockerfile | 15 ++++--- bin/build.sh | 7 +++- src/setup/Dockerfile | 98 -------------------------------------------- 3 files changed, 15 insertions(+), 105 deletions(-) delete mode 100644 src/setup/Dockerfile diff --git a/Dockerfile b/Dockerfile index 5238416..f55b1a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM ubuntu:22.04 RUN apt-get -y update && \ apt-get install -y sudo python3 python3-pip \ - gcc git python3-dev libssl-dev libffi-dev cron \ + gcc git python3-dev libssl-dev libffi-dev \ python3-lxml apache2 libapache2-mod-wsgi-py3 \ - mariadb-server python3-pymysql + mariadb-server python3-pymysql vim nano wget RUN sudo pip3 install cffi cryptography Flask \ launchpadlib simplejson requests pytest \ @@ -16,15 +16,20 @@ WORKDIR /opt/software-discovery-tool RUN git submodule update --init --recursive --remote -RUN cp src/config/supported_distros.py.example src/config/supported_distros.py +RUN mv src/config/supported_distros.py.example src/config/supported_distros.py && \ + mv .env.example .env RUN bash -c "echo 'export PYTHONPATH=/opt/software-discovery-tool/src/classes:/opt/software-discovery-tool/src/config:$PYTHONPATH' > /etc/profile.d/software-discovery-tool.sh" RUN cp -f /opt/software-discovery-tool/src/config/sdt.conf /etc/apache2/sites-available/sdt.conf && \ mv /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/z-000-default.conf -RUN useradd apache && \ +RUN useradd -s /usr/bin/bash apache && \ chown -R apache:apache /opt/software-discovery-tool/ +RUN a2dissite 000-default.conf && \ + a2ensite sdt.conf + RUN apachectl restart -USER apache + +#USER apache diff --git a/bin/build.sh b/bin/build.sh index 2d750ba..f97bcc6 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,5 +1,8 @@ # check if every .example is renamed to original -# check if root password in env file has changed or not +# warn db hostname is localhost +#check if root password in env file has changed or not # print if there are previous images in the system for sdt # add instruction how to remove them -# docker build and run +# docker build +# prep mariadb +# docker run diff --git a/src/setup/Dockerfile b/src/setup/Dockerfile deleted file mode 100644 index 6c33d9d..0000000 --- a/src/setup/Dockerfile +++ /dev/null @@ -1,98 +0,0 @@ -################# Dockerfile for software-discovery-tool ##################### -# -# This Dockerfile builds a basic installation of software-discovery-tool. -# -# -# To build this image, from the directory containing this Dockerfile -# (assuming that the file is named Dockerfile): -# docker build -t . -# -# To Start software-discovery-tool use the following command. -# docker run --name -p :80 -d -# -# Test in the browser by using the following url: -# http://:/ -# http://:/software-discovery-tool -# -# Or by running the provided unit-tests: -# cd /opt/software-discovery-tool/src/tests -# pytest -######################################################################################## - -# Base image - FROM s390x/ubuntu:16.04 - -# The author - MAINTAINER LoZ Open Source Ecosystem (https://www.ibm.com/developerworks/community/groups/community/lozopensource) - -# Set environment variable - ENV SOURCE_DIR=/home - WORKDIR $SOURCE_DIR - -# Install dependencies -RUN apt-get update && apt-get install -y \ - python3 \ - python3-pip \ - gcc \ - git \ - python3-dev \ - libssl-dev \ - libffi-dev \ - cron \ - python3-lxml \ - apache2 \ - libapache2-mod-wsgi-py3 \ - -&& pip3 install 'cffi==1.11.5' \ - 'cryptography==1.4' \ - Flask \ - launchpadlib \ - simplejson \ - requests \ - pytest - - -#Set Environmental Variables -RUN echo $PATH -ENV PATH=/usr/local/bin:$PATH -RUN sh -c "echo 'export PATH=/usr/local/bin:$PATH' > /etc/profile.d/alternate_install_path.sh" - -# Clone software-discovery-tool from git -RUN cd /opt/ \ -&& git clone https://github.com/openmainframeproject/software-discovery-tool.git \ -&& cd software-discovery-tool \ - - -# Set Environmental Variables -&& sh -c "echo 'export PYTHONPATH=/opt/software-discovery-tool/src/classes:/opt/software-discovery-tool/src/config:$PYTHONPATH' > /etc/profile.d/software-discovery-tool.sh" \ - -# Copy the apache configuration file from /opt/software-discovery-tool/src/config/sdt.conf into respective apache configuration folder as below -&& cp -f /opt/software-discovery-tool/src/config/sdt.conf /etc/apache2/sites-enabled/sdt.conf \ -&& mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/z-000-default.conf \ - -#Create new user and group for apache -&& useradd apache \ - - -#Set appropriate folder and file permission on /opt/software-discovery-tool/ folder for apache -&& chown -R apache:apache /opt/software-discovery-tool/ \ - -# Clean up cache , source data and un-used packages - -&& apt-get remove -y \ - gcc \ - git \ - libssl-dev \ - libffi-dev \ - cron \ - && apt-get autoremove -y \ - && apt autoremove -y \ - && apt-get clean && rm -rf /var/lib/apt/lists/* $SOURCE_DIR - -# Expose port -EXPOSE 80 - -# Start Apache Http Server -CMD ["apachectl","-D", "FOREGROUND"] - -# End of Dockerfile From cc1a2a692afe1d91754eabcd10c221c36bba876f Mon Sep 17 00:00:00 2001 From: rachejazz Date: Wed, 24 Jul 2024 18:40:41 +0100 Subject: [PATCH 3/3] test: change branch Signed-off-by: rachejazz --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index f55b1a5..261ff81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN git submodule update --init --recursive --remote RUN mv src/config/supported_distros.py.example src/config/supported_distros.py && \ mv .env.example .env +RUN git fetch && git checkout remotes/origin/data-update-fixes RUN bash -c "echo 'export PYTHONPATH=/opt/software-discovery-tool/src/classes:/opt/software-discovery-tool/src/config:$PYTHONPATH' > /etc/profile.d/software-discovery-tool.sh" RUN cp -f /opt/software-discovery-tool/src/config/sdt.conf /etc/apache2/sites-available/sdt.conf && \