Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building HammerDB for Docker from previous tagged versions will still build the latest release #771

Open
DGonzalezVillal opened this issue Dec 16, 2024 · 4 comments
Assignees
Labels
docker docker file and image related

Comments

@DGonzalezVillal
Copy link

DGonzalezVillal commented Dec 16, 2024

Describe the bug
When trying to build old versions of hammerDB for Docker, the current Dockerfiles will still build the latest release.

To Reproduce

  1. Clone the repository
  2. Checkout the desired docker release (i.e. v4.11-docker)
  3. Go into the Docker directory
  4. Build the Docker image
  5. Run docker image with bash
  6. Check hammerDB version inside of the container. Latest version of hammerDB will be present and not the desired older version.

Expected behavior
Inside of the container we should see the checkout version of hammerDB

HammerDB Version (please complete the following information):

  • Version: 4.12 and previous
  • Build: Docker

HammerDB Interface (please complete the following information):

  • UI: CLI

Operating System (please complete the following information):

  • Server OS: Tested on RHEL 9.5

Additional context
I already brought up this issue in the Q&A:
#769 (reply in thread)

The current workaround is to modify the DockerFile to point to the desired hammerDB version on the docker repository.

@sm-shaw sm-shaw added the docker docker file and image related label Dec 17, 2024
@sm-shaw sm-shaw self-assigned this Dec 17, 2024
@sm-shaw
Copy link
Contributor

sm-shaw commented Dec 17, 2024

Issue is this line in the dockerfile pulls the latest base:
=> [internal] load metadata for docker.io/tpcorg/hammerdb:base

As a workaround, if you edit the Dockerfiles, so the main one has the first 2 lines as:

FROM  docker.io/tpcorg/hammerdb:v4.11 as oracle
FROM  docker.io/tpcorg/hammerdb:v4.11

and in the database specific directories it has this

FROM docker.io/tpcorg/hammerdb:v4.11 rather than hammerdb:base

it works but in the database specific builds it builds everything for hammerdb:v4.11 and therefore needs a solution to specify the v4.11 base instead.

@pooja-jain-17 and @grooverdan as you have updated the Dockerfiles before do you have any suggestions for how we can achieve this?

@grooverdan
Copy link
Contributor

The Docker/base/Dockerfile has build argument of HAMMERDB_VERSION and the build version of it is define by this rather than the checked out github repo tag. If building locally, then this is an approach, or like @sm-shaw indicated that using an explicitly tagged FROM rather than hammerdb:base, or recreate hammerdb:base locally with a buildarg of HAMMERDB_VERSION=v4.something and then build for the desired DBs.

Previously there has been in https://hub.docker.com/r/tpcorg/hammerdb/tags tags like v4.10-mysql. To facilitate use cases like @DGonzalezVillal , I suggest continuing this naming convention.

With enforced with automation around releases this should be much more consistent. Github actions like https://github.com/redhat-actions/buildah-build triggered off tag pushes should facilitate this quite easily.

While hammerdb: base is a convenient building point for other containers is it useful as a distributed container? Pushing only derived containers will work and preserve the layering without giving the impression of a purposeful product.

Apart from automation in release and perhaps documenting the how to build a specific version locally, I'm not sure any other repo changes will make this resolvable.

If a build that corresponds to a the codebase is desired, a Dockerfile, like base, except with COPY {localdir} {containerdir} that achieves the same layout as RUN wget ... would facilitate local development, if that is the goal.

@sm-shaw
Copy link
Contributor

sm-shaw commented Dec 18, 2024

Thank-you @grooverdan this should give us a good starting point to get this resolved for the next release.

@sm-shaw
Copy link
Contributor

sm-shaw commented Jan 21, 2025

The proposed update allows the hard-coded workaround to instead be specified at the commandline so if we update the main Dockerfile as:

ARG HAMMERDB_VERSION=latest

FROM docker.io/tpcorg/hammerdb:${HAMMERDB_VERSION} AS oracle
FROM docker.io/tpcorg/hammerdb:${HAMMERDB_VERSION} AS mssqls

# Install and configure IBM Db2 client libraries, 
# You will need to pre-download IDB Db2 client libraries and place in the local 
folder
# RUN mkdir -p db2_cli_odbc_driver/odbc_cli
# ADD odbc_cli db2_cli_odbc_driver/odbc_cli/
# RUN apt update && \
#    echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
#    apt -y install libxml2 && \
#    echo 'export DB2_CLI_DRIVER_INSTALL_PATH="/home/db2_cli_odbc_driver/odbc_cli/clidriver"' >> ~/.bashrc && \
#    echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/db2_cli_odbc_driver/odbc_cli/clidriver/lib"' >> ~/.bashrc && \
#    echo 'export LIBPATH="/home/db2_cli_odbc_driver/odbc_cli/clidriver/lib"' >> ~/.bashrc && \
#    echo 'export PATH="$PATH:/home/db2_cli_odbc_driver/odbc_cli/clidriver/bin"' >> ~/.bashrc && \
#    echo 'export PATH="$PATH:/home/db2_cli_odbc_driver/odbc_cli/clidriver/adm"'>>  ~/.bashrc

COPY --from=oracle /home/instantclient_21_5 /home/instantclient_21_5
ENV ORACLE_LIBRARY=/home/instantclient_21_5/libclntsh.so
RUN echo 'export LD_LIBRARY_PATH=/home/instantclient_21_5/:$LD_LIBRARY_PATH'  >> ~/.bashrc

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y libmariadb3 libpq-dev libm
ysqlclient21 && \
    rm -rf /var/lib/apt/lists/*

and the Dockerfile in the base directory:

FROM       ubuntu:20.04
LABEL maintainer="Pooja Jain"

# Update & upgrade apt and download basic utilities
RUN apt-get update && \
    apt-get -y upgrade && \
    apt-get -y install -q && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y wget unzip gnupg apt-utils libaio1 iputils
-ping vim netcat libxft-dev libcairo2-dev xauth python3 && \
    rm -rf  /var/lib/apt/lists/*

# Install configure HammerDB-v4.12
ARG HAMMERDB_VERSION=4.12
RUN wget https://github.com/TPC-Council/HammerDB/releases/download/v$HAMMERDB_VERSION/HammerDB-$
HAMMERDB_VERSION-Linux.tar.gz -O - | \
    tar -xvzf - -C /home/ && \
    ln -s /home/HammerDB-$HAMMERDB_VERSION /home/hammerdb

WORKDIR /home/hammerdb

CMD tail -f /dev/null

Then if we build with the command

docker build --build-arg HAMMERDB_VERSION=v4.11 -t hammerdb:mariadb-v4.11 .

it gives a version specific build:

and if we use:

docker build -t hammerdb .

it defaults to the latest.

Database specific builds will still pull the latest base but if needs be we can push versioned base images like hammerdb:v5.0-base so this will be possible going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker docker file and image related
Projects
None yet
Development

No branches or pull requests

3 participants