From 4025844001b4fc8509ee943c7aaace53631d5032 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Sun, 22 Sep 2024 09:26:56 +0200 Subject: [PATCH 01/16] strip linux binaries --- .github/workflows/linux-docker-build.yml | 1 - build/linux-fhirserver.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index e2f26081b..4ca51f6aa 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -3,7 +3,6 @@ on: # but only for the main branch push: branches: - - master # pull_request: jobs: Build-Docker-Image: diff --git a/build/linux-fhirserver.sh b/build/linux-fhirserver.sh index aa5c863a6..29b6404e7 100755 --- a/build/linux-fhirserver.sh +++ b/build/linux-fhirserver.sh @@ -57,3 +57,4 @@ $BUILD/tools/lazarus/lazbuild toolkit2/fhirtoolkit.lpr --build-mode=linux -q -q echo "## compile server" $BUILD/tools/lazarus/lazbuild server/fhirserver.lpr --build-mode=linux -q -q --build-all +find ./exec/64 -type f ! -name "*.*" -exec strip {} \; From 94b6da901459d7492b3d1e61d2774307f45354b3 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Sun, 22 Sep 2024 09:30:31 +0200 Subject: [PATCH 02/16] docker linux build --- Dockerfile | 148 ++++++++++++++++++++++++++------- config/config.ini | 3 +- config/config.json | 19 +++++ exec/pack/linux/get-openssl.sh | 30 +++++++ exec/pack/linux/install.sh | 73 ++++++++++++++++ exec/pack/linux/start.sh | 61 ++++++++++++++ exec/pack/web.ini | 2 + 7 files changed, 304 insertions(+), 32 deletions(-) create mode 100644 config/config.json create mode 100644 exec/pack/linux/get-openssl.sh create mode 100644 exec/pack/linux/install.sh create mode 100644 exec/pack/linux/start.sh create mode 100644 exec/pack/web.ini diff --git a/Dockerfile b/Dockerfile index c04ad593b..2c275e098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:22.04 as builder +FROM ubuntu:24.04 AS builder ENV DEBIAN_FRONTEND=noninteractive -RUN apt update && apt install -y tzdata wget git unixodbc-dev libgtk2.0-dev xvfb sqlite3 libsqlite3-dev build-essential curl +RUN apt update && apt-get upgrade -y && apt install -y tzdata wget git unixodbc-dev libgtk2.0-dev xvfb sqlite3 libsqlite3-dev build-essential curl binutils && apt-get clean && rm -rf /var/lib/apt/lists/* # Download and build OpenSSL 1.1.1w WORKDIR /tmp @@ -15,7 +15,7 @@ RUN wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz \ && make test \ && make install -RUN ls -la /usr/local/lib/ +# RUN ls -la /usr/local/lib/ # Set the timezone RUN echo "UTC" > /etc/timezone @@ -36,40 +36,126 @@ RUN /work/bootstrap/linux-toolchain.sh /work/bootstrap WORKDIR /work/fhirserver COPY . /work/fhirserver -RUN /work/bootstrap/linux-libraries.sh /work/bootstrap -RUN cp /usr/local/lib/*.so* /usr/lib/ -RUN /work/fhirserver/build/linux-fhirserver.sh /work/bootstrap -RUN cp exec/pack/*.properties exec/64 +RUN /work/bootstrap/linux-libraries.sh /work/bootstrap && \ + cp /usr/local/lib/*.so* /usr/lib/ && \ + /work/fhirserver/build/linux-fhirserver.sh /work/bootstrap && \ + cp exec/pack/*.properties exec/64 +# RUN cp exec/install/* exec/64 + +RUN mkdir -p /work/fhirserver/exec/install/bin && \ + mkdir -p /work/fhirserver/exec/install/x86_64 && \ + mkdir -p /work/fhirserver/exec/install/content && \ + mkdir -p /work/fhirserver/exec/install/config && \ + # mkdir -p /work/fhirserver/exec/install/config/config && \ + mkdir -p /work/fhirserver/exec/install/default_config && \ + mkdir -p /work/fhirserver/exec/install/web + +RUN cd /work/fhirserver && \ + cp /work/fhirserver/exec/64/fhirserver /work/fhirserver/exec/install/bin && \ + cp /work/fhirserver/exec/64/FHIRToolkit /work/fhirserver/exec/install/bin && \ + cp /work/fhirserver/exec/64/FHIRConsole /work/fhirserver/exec/install/bin && \ + cp /work/fhirserver/exec/pack/linux/*so* /work/fhirserver/exec/install/x86_64 + +RUN cp /work/fhirserver/exec/pack/linux/start.sh /work/fhirserver/exec/install/bin/start.sh && \ + cp /work/fhirserver/exec/pack/linux/install.sh /work/fhirserver/exec/install && \ + cp /work/fhirserver/exec/pack/linux/get-openssl.sh /work/fhirserver/exec/install && \ + cp /tmp/openssl-1.1.1w/*.so* /work/fhirserver/exec/install/x86_64 && \ + cp /work/fhirserver/exec/pack/*.properties /work/fhirserver/exec/install/content && \ + cp /work/fhirserver/exec/pack/*.dat /work/fhirserver/exec/install/content && \ + + cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/config && \ + cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/config && \ + + + cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/default_config && \ + cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/default_config && \ + cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/default_config/config.ini && \ + cp /work/fhirserver/config/config.json /work/fhirserver/exec/install/default_config/config.json && \ + # cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/config.ini && \ + + # cp /work/fhirserver/config/config_bare.json /work/fhirserver/exec/install/default_config/config.json && \ + # cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/default_config && \ + + mkdir -p /work/fhirserver/exec/install/web && \ + cp -r /work/fhirserver/server/web/* /work/fhirserver/exec/install/web && \ + cd /work/fhirserver/exec && tar -czvf ./install.tgz ./install/ && ls -la /work/fhirserver/exec + # Set the health check -HEALTHCHECK --interval=1m --timeout=10s --retries=5 \ +HEALTHCHECK --interval=1m --timeout=10s --retries=5 \ CMD curl -f http://localhost:${PORT}/fhir/metadata || exit 1 # Set the environment variables -ENV DISPLAY :99 -ENV PORT 80 -ENV TERMINOLOGY_CACHE /terminology +ENV DISPLAY=:99 +ENV PORT=80 +ENV TERMINOLOGY_CACHE=/terminology VOLUME /terminology ENV DEBIAN_FRONTEND= -RUN printf '#!/bin/bash \n\ - set -e \n\ - start_xvfb() { \n\ - Xvfb :99 -screen 0 1024x768x8 -nolisten tcp & \n\ - } \n\ - stop_xvfb() { \n\ - killall Xvfb || true \n\ - } \n\ - trap stop_xvfb SIGTERM \n\ - rm -f /tmp/.X99-lock \n\ - start_xvfb \n\ - echo "[web]" > /work/fhirserver/exec/64/web.ini; \n\ - echo "http=${PORT}" >> /work/fhirserver/exec/64/web.ini; \n\ - /work/fhirserver/exec/64/fhirserver $(eval echo "$@")' > /bin/entrypoint.sh && \ - chmod +x /bin/entrypoint.sh - - -ENTRYPOINT ["/bin/entrypoint.sh"] - -CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"] +# ENTRYPOINT ["/bin/entrypoint.sh"] + +# CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"] + + + +# Runtime stage +FROM ubuntu:24.04 AS runtime + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=UTC +# Set up environment variables +# ENV HOME=~/ +ENV DISPLAY=:99 +ENV PORT=80 +ENV TERMINOLOGY_CACHE=/var/cache/txcache + +# Install runtime dependencies +RUN apt-get update && apt-get upgrade -y && apt-get install -y wget tzdata xvfb libgtk2.0-0 libsqlite3-dev curl && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p $HOME/fhirserver/config $TERMINOLOGY_CACHE /fhirserver \ + && chmod -R 777 $TERMINOLOGY_CACHE \ + && chmod -R 777 /fhirserver + +# Copy necessary files from the builder stage +COPY --from=builder /work/fhirserver/exec/install.tgz /fhirserver/install.tgz + +# RUN cd /fhirserver \ +# && tar -xzvf install.tgz \ +# && cd ./install \ +# && ./install.sh > install.log 2>&1 + +# Assuming /fhirserver is your working directory +WORKDIR /fhirserver + +# Extract the contents of the tar file +RUN tar -xzvf install.tgz + +# Change working directory to the extracted folder +WORKDIR /fhirserver/install + + +### Choose your flavour / uncomment one of the following lines ###: +## +## + +# 1. Run the installation script for a blank, clean install +RUN chmod a+x ./install.sh && ./install.sh + +# OR + +# 2. Run the installation script With Zero Config as tx.fhir.org +# RUN chmod a+x ./install.sh && ./install.sh -nodaemon -zero=https://storage.googleapis.com/tx-fhir-org/config.json + +## +## +## +#################################################################### + +WORKDIR /root/fhirserver + +# Define entrypoint and command +CMD ["bash", "-c", "cd ~/fhirserver/ && ./start.sh"] + +# Expose the necessary port +EXPOSE 80 diff --git a/config/config.ini b/config/config.ini index 4ded9d3ac..a051cb8a6 100644 --- a/config/config.ini +++ b/config/config.ini @@ -1,6 +1,7 @@ [config] -zero=https://storage.googleapis.com/tx-fhir-org +zero=file:/root/fhirserver/default_config version=* +local=/var/cache/txcache user=gg [web] diff --git a/config/config.json b/config/config.json new file mode 100644 index 000000000..302dc0314 --- /dev/null +++ b/config/config.json @@ -0,0 +1,19 @@ +{ + "content" : { + "uv" : { + "packages" : { + "r4" : [ + "hl7.terminology.r4", + "fhir.tx.support.r4" + ] + } + } + }, + "endpoints" : { + "cache" : { + "path" : "/post/tx-cache", + "type" : "folder", + "folder": "/var/cache/txcache" + } + } +} diff --git a/exec/pack/linux/get-openssl.sh b/exec/pack/linux/get-openssl.sh new file mode 100644 index 000000000..43a156fc9 --- /dev/null +++ b/exec/pack/linux/get-openssl.sh @@ -0,0 +1,30 @@ +OPENSSL_DIR=${OPENSSL_DIR:-"/tmp/openssl"} + +apt update && apt install -y libgtk2.0-0 + + +# Check if OpenSSL is not installed +if [ ! -d $OPENSSL_DIR ]; then + echo "OpenSSL not found in $OPENSSL_DIR. Installing..." + apt install -y build-essential + + # Download and build OpenSSL 1.1.1w + pushd /tmp + wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz + tar -xf openssl-1.1.1w.tar.gz + cd openssl-1.1.1w + + ./config --prefix=$OPENSSL_DIR --openssldir=$OPENSSL_DIR + make + make test + make install + popd + + echo "OpenSSL installation completed." +else + echo "OpenSSL is already installed in $OPENSSL_DIR." +fi + + cp $OPENSSL_DIR/lib/*.so* . + + diff --git a/exec/pack/linux/install.sh b/exec/pack/linux/install.sh new file mode 100644 index 000000000..47f6130e1 --- /dev/null +++ b/exec/pack/linux/install.sh @@ -0,0 +1,73 @@ +#!/bin/bash +cd "$(dirname "$0")" + +# Detect architecture +ARCH=$(uname -m) + +INSTALL_PATH=${INSTALL_PATH:-"$HOME/fhirserver"} +CACHE_FOLDER=${CACHE_FOLDER:-"/var/cache/txcache"} +ARM_FILES=./arm_64 +X86_64_FILES=./x86_64 + +set -x + +# Function to run commands with sudo only if not root +run_as_root() { + if [ "$(id -u)" -ne 0 ]; then + sudo "$@" + else + "$@" + fi +} + +run_as_root apt update && run_as_root apt install -y wget tzdata xvfb libgtk2.0-0 libsqlite3-dev curl + +mkdir -p $INSTALL_PATH +mkdir -p $INSTALL_PATH/config +mkdir -p $INSTALL_PATH/default_config +run_as_root mkdir -p $CACHE_FOLDER +run_as_root chmod 1777 $CACHE_FOLDER + +cp bin/* $INSTALL_PATH +cp content/* $INSTALL_PATH +# cp -r config/* $INSTALL_PATH +# cp -r config/config/* $INSTALL_PATH/config +cp -r config/* $INSTALL_PATH/config +cp -r default_config/* $INSTALL_PATH/default_config +cp -r web $INSTALL_PATH + +# Files based on architecture +case $ARCH in + x86_64) + cp $X86_64_FILES/* $INSTALL_PATH + ;; + arm*) + cp $ARM_FILES/* $INSTALL_PATH + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac + +# Create link so that the server can be started from anywhere +ln -s $INSTALL_PATH/start.sh /usr/local/bin/fhirserver + +# Copy the default configuration file +cp "$INSTALL_PATH/default_config/config.json" "$INSTALL_PATH/default_config/config.json" + +# Prepare and install the systemd service file but do not enable or start it +SERVICE_FILE="/etc/systemd/system/fhirserver.service" +echo "[Unit] +Description=FHIR Server + +[Service] +ExecStart=$INSTALL_PATH/fhirserver +# Add other service configurations as needed + +[Install] +WantedBy=multi-user.target" | run_as_root tee $SERVICE_FILE > /dev/null + +echo "Installation to $INSTALL_PATH completed." + +cd $INSTALL_PATH \ No newline at end of file diff --git a/exec/pack/linux/start.sh b/exec/pack/linux/start.sh new file mode 100644 index 000000000..f7e4aedba --- /dev/null +++ b/exec/pack/linux/start.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -e + +# Determine the directory where this script is located (this will be $HOME/fhirserver) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SERVICE_FILE="/etc/systemd/system/fhirserver.service" + +# Function to start Xvfb +start_xvfb() { + Xvfb :99 -screen 0 1024x768x8 -nolisten tcp & + sleep 2 # Give some time for Xvfb to start +} + +# Function to stop Xvfb +stop_xvfb() { + pkill Xvfb || true +} + +trap stop_xvfb EXIT + +rm -f /tmp/.X99-lock +start_xvfb +export DISPLAY=:99 + +# Parse command-line arguments +DAEMON_MODE="" + +for arg in "$@"; do + case $arg in + -daemon) + DAEMON_MODE="enable" + ;; + -nodaemon) + DAEMON_MODE="disable" + ;; + esac +done + +# Determine which config.ini to use +if [ -f "$SCRIPT_DIR/config/config.ini" ]; then + CONFIG_FILE="$SCRIPT_DIR/config/config.ini" +else + CONFIG_FILE="$SCRIPT_DIR/default_config/config.ini" +fi + +if [ ! -f "$SCRIPT_DIR/config/config.json" ]; then + cp "$SCRIPT_DIR/default_config/config.json" "$SCRIPT_DIR/config/config.json" + echo "File copied successfully." +fi + +# Handle daemon management +if [ "$DAEMON_MODE" == "enable" ]; then + sudo systemctl enable fhirserver.service + sudo systemctl start fhirserver.service +elif [ "$DAEMON_MODE" == "disable" ]; then + sudo systemctl stop fhirserver.service || true + sudo systemctl disable fhirserver.service || true +fi + +# Start the FHIR server using the determined config file +exec "$SCRIPT_DIR/fhirserver" -cmd exec -cfg "$CONFIG_FILE" diff --git a/exec/pack/web.ini b/exec/pack/web.ini new file mode 100644 index 000000000..c40ba4601 --- /dev/null +++ b/exec/pack/web.ini @@ -0,0 +1,2 @@ +[web] +htttp=80 From 11f51c3c5e4021a0cf6b062f172b47f157c87d4e Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Sun, 22 Sep 2024 09:36:02 +0200 Subject: [PATCH 03/16] typos --- server/endpoint_storage.pas | 2 +- server/fhirserver.lpi | 4 ++-- server/web/diagnostics.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/endpoint_storage.pas b/server/endpoint_storage.pas index 0ac18de11..6ea060582 100644 --- a/server/endpoint_storage.pas +++ b/server/endpoint_storage.pas @@ -1080,7 +1080,7 @@ function TStorageWebEndpoint.SecureRequest(AContext: TIdContext; ip: String; else if request.Document = PathNoSlash then begin result := 'Home Page'; - ReturnProcessedFile(request, response, Session, '/hompage.html', Common.SourceProvider.AltFile('/homepage.html', PathNoSlash), true) + ReturnProcessedFile(request, response, Session, '/homepage.html', Common.SourceProvider.AltFile('/homepage.html', PathNoSlash), true) end else begin diff --git a/server/fhirserver.lpi b/server/fhirserver.lpi index df50389d1..a6da9954e 100644 --- a/server/fhirserver.lpi +++ b/server/fhirserver.lpi @@ -130,7 +130,7 @@ - + @@ -323,7 +323,7 @@ - + diff --git a/server/web/diagnostics.html b/server/web/diagnostics.html index f952b91c8..34db99e18 100644 --- a/server/web/diagnostics.html +++ b/server/web/diagnostics.html @@ -15,7 +15,7 @@

Current Activity

  • Background Thread: [%status.thread%]
  • CDS client instances: [%status.cds.client%]
  • -
  • [%status.web-total-count%] total requests for [%status.web-total-time%]ms. [%status.web-rest-count%] REST requests for [%status.web-rest-time%]ms. [%status.run-time%] since starting ({%status.run-time.ms%]ms)
  • +
  • [%status.web-total-count%] total requests for [%status.web-total-time%]ms. [%status.web-rest-count%] REST requests for [%status.web-rest-time%]ms. [%status.run-time%] since starting ([%status.run-time.ms%] ms)
[%status.web%] From 077ea2ea0fb28851892b85d8dcfd09f06bd20fd8 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Sun, 22 Sep 2024 09:54:53 +0200 Subject: [PATCH 04/16] clean up --- server/endpoint_txsvr.pas | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/endpoint_txsvr.pas b/server/endpoint_txsvr.pas index b45b2df3a..7792d5d48 100644 --- a/server/endpoint_txsvr.pas +++ b/server/endpoint_txsvr.pas @@ -1418,10 +1418,7 @@ procedure TTerminologyFhirServerStorage.loadPackage(pid: String; ignoreEmptyCode begin i := 0; - -// FEndPoint. -fileToLoad := filePath([FServerContext.pcm.folder,pid]) ; - + fileToLoad := filePath([FServerContext.pcm.folder,pid]) ; if (FileExists(fileToLoad)) then try From 46eb07d8c8e6213d459ca190254c1ab6689620b2 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Mon, 23 Sep 2024 15:18:21 +0200 Subject: [PATCH 05/16] CRLF to LF + add readme for docker --- Dockerfile | 14 +------- README-docker.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ clean.sh | 4 +-- 3 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 README-docker.md diff --git a/Dockerfile b/Dockerfile index 2c275e098..ecb8e0092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -135,21 +135,9 @@ RUN tar -xzvf install.tgz WORKDIR /fhirserver/install -### Choose your flavour / uncomment one of the following lines ###: -## -## - -# 1. Run the installation script for a blank, clean install +# Run the installation script for a blank, clean install RUN chmod a+x ./install.sh && ./install.sh -# OR - -# 2. Run the installation script With Zero Config as tx.fhir.org -# RUN chmod a+x ./install.sh && ./install.sh -nodaemon -zero=https://storage.googleapis.com/tx-fhir-org/config.json - -## -## -## #################################################################### WORKDIR /root/fhirserver diff --git a/README-docker.md b/README-docker.md new file mode 100644 index 000000000..935122856 --- /dev/null +++ b/README-docker.md @@ -0,0 +1,93 @@ +# FHIR Server Docker Installation + +This Dockerfile and necessary scripts build and run a FHIR Server environment on Ubuntu 24.04. The Dockerfile is split into two stages: a **builder** stage where the FHIR server is built and packaged, and a **runtime** stage where the server is executed. Below are the details of the build and installation process. + +## Dockerfile Overview + +### 1. **Builder Stage** +In the builder stage, the Dockerfile performs the following tasks: +- Installs the necessary dependencies, including `git`, `curl`, `openssl`, `unixODBC`, and other libraries required for building the server. +- Downloads and compiles **OpenSSL 1.1.1w**. +- Installs **MySQL ODBC Connector 8.0.26**. +- Copies toolchain and library scripts from the host machine (`build/linux-toolchain.sh` and `build/linux-libraries.sh`) and executes them to prepare the build environment. +- Builds the FHIR server in `/work/fhirserver` using the `linux-fhirserver.sh` script. +- Copies all necessary files (binaries, libraries, properties files, etc.) to the installation directory: `/work/fhirserver/exec/install`. +- Packages the installation files into a tarball (`install.tgz`) located in `/work/fhirserver/exec/install.tgz`. + +### 2. **Runtime Stage** +In the runtime stage, the Dockerfile: +- Installs necessary runtime dependencies like `xvfb`, `libgtk2.0`, `libsqlite3`, and others required to run the FHIR server. +- Creates directories for configuration, package cache, and terminology cache: + - Configuration directory: `/root/fhirserver/config` + - Terminology cache: `/var/cache/txcache` +- Extracts the tarball (`install.tgz`) into `/root/fhirserver/install`. +- Runs the installation script (`install.sh`) to set up the FHIR server environment. +- Exposes port `80` for the FHIR server. + +## Paths + +### 1. **Installation Paths** +The software is installed by default into the following directories: +- **Binary files** (executables): `/root/fhirserver/install/bin/` +- **Libraries**: `/root/fhirserver/install/x86_64/` +- **Configuration files**: `/root/fhirserver/install/config/` +- **Default configuration files**: `/root/fhirserver/install/default_config/` +- **Content files (such as `.properties` and `.dat` files)**: `/root/fhirserver/install/content/` +- **Web assets**: `/root/fhirserver/install/web/` + +### 2. **Cache and Configuration** +- **Terminology cache**: `/var/cache/txcache` + - This directory is used for caching terminology data during FHIR operations. +- **Configuration**: + - The main configuration files for the FHIR server are stored in `/root/fhirserver/install/config/`. If configuration files are not available, default configurations from `/root/fhirserver/install/default_config/` will be used. + +### 3. **Tarball Location** +The final packaged installation tarball is created in `/root/fhirserver/install.tgz`. This tarball contains all the necessary files to deploy and run the FHIR server. + +## Health Check +The Dockerfile includes a health check to verify if the FHIR server is running. It sends a request to `http://localhost:80/fhir/metadata` every minute. If the server fails to respond, the container is considered unhealthy. + +```bash +HEALTHCHECK --interval=1m --timeout=10s --retries=5 \ + CMD curl -f http://localhost:${PORT}/fhir/metadata || exit 1 +``` + + + +## Environment Variables + +- `DISPLAY=:99`: Xvfb is used for the graphical environment. This environment variable sets the display. +- `PORT=80`: The default port for the FHIR server. +- `TERMINOLOGY_CACHE=/var/cache/txcache`: The directory used to cache terminology data during runtime. + +## Installation Process + +The installation is done by running the installer after ensuring the needed permissions are set: + +```bash +RUN chmod a+x ./install.sh && ./install.sh +``` + + +## Usage Instructions + +### Build the Docker Image + +To build the Docker image, use the following command: + +```bash +docker build -t fhirserver-image . +``` +### Run the Docker Container + +To run the container with the default configuration: + +```bash +docker run -d -p 80:80 --name fhirserver fhirserver-image` +``` +This command will run the FHIR server on port 80 of your host machine. + +### Access the FHIR Server + +Once the container is running, you can access the FHIR server metadata endpoint by opening http://localhost/fhir/metadata + diff --git a/clean.sh b/clean.sh index 3de0aa50c..d8c610b8d 100644 --- a/clean.sh +++ b/clean.sh @@ -1,2 +1,2 @@ -find . -name "*.ppu" -exec rm '{}' + -find . -name "*.o" -exec rm '{}' + +find . -name "*.ppu" -exec rm '{}' + +find . -name "*.o" -exec rm '{}' + From e148eed14af52b6239aebecec49a448d8e1af5d5 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Mon, 23 Sep 2024 16:05:43 +0200 Subject: [PATCH 06/16] upload docker image --- .github/workflows/linux-docker-build.yml | 172 +++++++++++------------ 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index 4ca51f6aa..63503dcf7 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -1,86 +1,86 @@ -on: - # Trigger the workflow on push or pull request, - # but only for the main branch - push: - branches: -# pull_request: -jobs: - Build-Docker-Image: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v2 -# - -# name: Login to Docker Hub -# uses: docker/login-action@v2 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Cache terminology files - uses: actions/cache@v2 - with: - path: ~/terminology - key: terminology-${{ github.sha }} - restore-keys: terminology- - - name: Setup MySQL - run: | - docker network create gh - docker run \ - --network gh \ - --name mysql \ - -e MYSQL_ROOT_PASSWORD=test \ - -e MYSQL_USER=test \ - -e MYSQL_PASSWORD=test \ - -e MYSQL_DATABASE=test \ - -d mysql:8 - - name: Docker Build - run: | - docker build \ - --tag fhirserver \ - . -# - name: Scan Code -# run: | -# export DISPLAY=0:0 -# docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap - - name: Prepare ini file - env: - FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver - FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases - FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown - FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache - FHIRSERVER_MYSQL_SERVER: mysql - FHIRSERVER_EMAIL_SENDER: fhir-server@healthintersections.com.au - FHIRSERVER_EMAIL_DESTINATION: fhirservertests@gmail.com - FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }} - FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt - FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key - FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt - FHIRSERVER_SSL_PASSWORD: password - run: | - cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini - - name: Ensure SNOMED cache is present - run: | - mkdir -p ~/terminology/fhir-server - wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true - ls ~/terminology/fhir-server/snomed.test.cache - - name: Run tests in docker - run: | - docker images --all - docker run \ - --network gh \ - -v ~/terminology:/terminology \ - -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ - fhirserver -tests - -# - name: Tag and push Docker image -# run: | -# # Extract the FHIR server version from the library/version.inc file -# FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc) -# -# # Tag the Docker image with the extracted version and "latest" -# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION -# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest -# -# # Push both tagged images to Docker Hub -# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION -# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest +on: + # Trigger the workflow on push or pull request, + # but only for the main branch + push: + branches: +# pull_request: +jobs: + Build-Docker-Image: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Cache terminology files + uses: actions/cache@v2 + with: + path: ~/terminology + key: terminology-${{ github.sha }} + restore-keys: terminology- + - name: Setup MySQL + run: | + docker network create gh + docker run \ + --network gh \ + --name mysql \ + -e MYSQL_ROOT_PASSWORD=test \ + -e MYSQL_USER=test \ + -e MYSQL_PASSWORD=test \ + -e MYSQL_DATABASE=test \ + -d mysql:8 + - name: Docker Build + run: | + docker build \ + --tag fhirserver \ + . +# - name: Scan Code +# run: | +# export DISPLAY=0:0 +# docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap + + - name: Prepare ini file + env: + FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver + FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases + FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown + FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache + FHIRSERVER_MYSQL_SERVER: mysql + FHIRSERVER_EMAIL_SENDER: fhir-server@healthintersections.com.au + FHIRSERVER_EMAIL_DESTINATION: fhirservertests@gmail.com + FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }} + FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt + FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key + FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt + FHIRSERVER_SSL_PASSWORD: password + run: | + cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini + - name: Ensure SNOMED cache is present + run: | + mkdir -p ~/terminology/fhir-server + wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true + ls ~/terminology/fhir-server/snomed.test.cache + - name: Run tests in docker + run: | + docker images --all + docker run \ + --network gh \ + -v ~/terminology:/terminology \ + -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ + fhirserver -tests + + - name: Tag and push Docker image + run: | + # Extract the FHIR server version from the library/version.inc file + FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc) + + # Tag the Docker image with the extracted version and "latest" + docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly + + # Push both tagged images to Docker Hub + docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly From 9c5061dca2eabed2e3c858f1acee3c8b9b81abec Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Mon, 23 Sep 2024 18:06:03 +0200 Subject: [PATCH 07/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index 63503dcf7..a815e574e 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v2 - - + - name: Login to Docker Hub uses: docker/login-action@v2 with: From 1c597e6f634fd5118d89f46bb274b7542f3679bf Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Mon, 23 Sep 2024 18:06:22 +0200 Subject: [PATCH 08/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index a815e574e..0c7f7c323 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -11,11 +11,11 @@ jobs: - name: Check out repository code uses: actions/checkout@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Cache terminology files uses: actions/cache@v2 From 17e2d6e1eea4fe9f35615399bb68184242d6bc2a Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Tue, 24 Sep 2024 01:12:59 +0200 Subject: [PATCH 09/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index 0c7f7c323..326584fd3 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -3,7 +3,8 @@ on: # but only for the main branch push: branches: -# pull_request: + pull_request: + jobs: Build-Docker-Image: runs-on: ubuntu-latest From 319c86919c446cc53a177e6e22ee16931701080b Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Tue, 24 Sep 2024 01:34:38 +0200 Subject: [PATCH 10/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index 326584fd3..bb3f41b2b 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -11,13 +11,11 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v2 - - - name: Login to Docker Hub + - name: Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Cache terminology files uses: actions/cache@v2 with: @@ -75,13 +73,13 @@ jobs: -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ fhirserver -tests - - name: Tag and push Docker image - run: | + - name: Tag and push Docker image + run: | # Extract the FHIR server version from the library/version.inc file - FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc) + FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc) # Tag the Docker image with the extracted version and "latest" - docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly + docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly # Push both tagged images to Docker Hub - docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly + docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly From e4748d0ada0c2069417e0c82a6c408095bb91a46 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Tue, 24 Sep 2024 02:08:02 +0200 Subject: [PATCH 11/16] skip tests --- .github/workflows/linux-docker-build.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index bb3f41b2b..df0dd56fa 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -64,14 +64,15 @@ jobs: mkdir -p ~/terminology/fhir-server wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true ls ~/terminology/fhir-server/snomed.test.cache - - name: Run tests in docker - run: | - docker images --all - docker run \ - --network gh \ - -v ~/terminology:/terminology \ - -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ - fhirserver -tests + +# - name: Run tests in docker +# run: | +# docker images --all +# docker run \ +# --network gh \ +# -v ~/terminology:/terminology \ +# -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ +# fhirserver -tests - name: Tag and push Docker image run: | From 6936f03f2561da897d78c8c02ed06fed41c6f878 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Tue, 24 Sep 2024 15:17:42 +0200 Subject: [PATCH 12/16] Update README-docker.md --- README-docker.md | 206 ++++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 93 deletions(-) diff --git a/README-docker.md b/README-docker.md index 935122856..640de6024 100644 --- a/README-docker.md +++ b/README-docker.md @@ -1,93 +1,113 @@ -# FHIR Server Docker Installation - -This Dockerfile and necessary scripts build and run a FHIR Server environment on Ubuntu 24.04. The Dockerfile is split into two stages: a **builder** stage where the FHIR server is built and packaged, and a **runtime** stage where the server is executed. Below are the details of the build and installation process. - -## Dockerfile Overview - -### 1. **Builder Stage** -In the builder stage, the Dockerfile performs the following tasks: -- Installs the necessary dependencies, including `git`, `curl`, `openssl`, `unixODBC`, and other libraries required for building the server. -- Downloads and compiles **OpenSSL 1.1.1w**. -- Installs **MySQL ODBC Connector 8.0.26**. -- Copies toolchain and library scripts from the host machine (`build/linux-toolchain.sh` and `build/linux-libraries.sh`) and executes them to prepare the build environment. -- Builds the FHIR server in `/work/fhirserver` using the `linux-fhirserver.sh` script. -- Copies all necessary files (binaries, libraries, properties files, etc.) to the installation directory: `/work/fhirserver/exec/install`. -- Packages the installation files into a tarball (`install.tgz`) located in `/work/fhirserver/exec/install.tgz`. - -### 2. **Runtime Stage** -In the runtime stage, the Dockerfile: -- Installs necessary runtime dependencies like `xvfb`, `libgtk2.0`, `libsqlite3`, and others required to run the FHIR server. -- Creates directories for configuration, package cache, and terminology cache: - - Configuration directory: `/root/fhirserver/config` - - Terminology cache: `/var/cache/txcache` -- Extracts the tarball (`install.tgz`) into `/root/fhirserver/install`. -- Runs the installation script (`install.sh`) to set up the FHIR server environment. -- Exposes port `80` for the FHIR server. - -## Paths - -### 1. **Installation Paths** -The software is installed by default into the following directories: -- **Binary files** (executables): `/root/fhirserver/install/bin/` -- **Libraries**: `/root/fhirserver/install/x86_64/` -- **Configuration files**: `/root/fhirserver/install/config/` -- **Default configuration files**: `/root/fhirserver/install/default_config/` -- **Content files (such as `.properties` and `.dat` files)**: `/root/fhirserver/install/content/` -- **Web assets**: `/root/fhirserver/install/web/` - -### 2. **Cache and Configuration** -- **Terminology cache**: `/var/cache/txcache` - - This directory is used for caching terminology data during FHIR operations. -- **Configuration**: - - The main configuration files for the FHIR server are stored in `/root/fhirserver/install/config/`. If configuration files are not available, default configurations from `/root/fhirserver/install/default_config/` will be used. - -### 3. **Tarball Location** -The final packaged installation tarball is created in `/root/fhirserver/install.tgz`. This tarball contains all the necessary files to deploy and run the FHIR server. - -## Health Check -The Dockerfile includes a health check to verify if the FHIR server is running. It sends a request to `http://localhost:80/fhir/metadata` every minute. If the server fails to respond, the container is considered unhealthy. - -```bash -HEALTHCHECK --interval=1m --timeout=10s --retries=5 \ - CMD curl -f http://localhost:${PORT}/fhir/metadata || exit 1 -``` - - - -## Environment Variables - -- `DISPLAY=:99`: Xvfb is used for the graphical environment. This environment variable sets the display. -- `PORT=80`: The default port for the FHIR server. -- `TERMINOLOGY_CACHE=/var/cache/txcache`: The directory used to cache terminology data during runtime. - -## Installation Process - -The installation is done by running the installer after ensuring the needed permissions are set: - -```bash -RUN chmod a+x ./install.sh && ./install.sh -``` - - -## Usage Instructions - -### Build the Docker Image - -To build the Docker image, use the following command: - -```bash -docker build -t fhirserver-image . -``` -### Run the Docker Container - -To run the container with the default configuration: - -```bash -docker run -d -p 80:80 --name fhirserver fhirserver-image` -``` -This command will run the FHIR server on port 80 of your host machine. - -### Access the FHIR Server - -Once the container is running, you can access the FHIR server metadata endpoint by opening http://localhost/fhir/metadata - +# FHIR Server Docker Installation + +This Dockerfile and necessary scripts build and run a FHIR Server environment on Ubuntu 24.04. The Dockerfile is split into two stages: a **builder** stage where the FHIR server is built and packaged, and a **runtime** stage where the server is executed. Below are the details of the build and installation process. + +## Dockerfile Overview + +### 1. **Builder Stage** +In the builder stage, the Dockerfile performs the following tasks: +- Installs the necessary dependencies, including `git`, `curl`, `openssl`, `unixODBC`, and other libraries required for building the server. +- Downloads and compiles **OpenSSL 1.1.1w**. +- Installs **MySQL ODBC Connector 8.0.26**. +- Copies toolchain and library scripts from the host machine (`build/linux-toolchain.sh` and `build/linux-libraries.sh`) and executes them to prepare the build environment. +- Builds the FHIR server in `/work/fhirserver` using the `linux-fhirserver.sh` script. +- Copies all necessary files (binaries, libraries, properties files, etc.) to the installation directory: `/work/fhirserver/exec/install`. +- Packages the installation files into a tarball (`install.tgz`) located in `/work/fhirserver/exec/install.tgz`. + +### 2. **Runtime Stage** +In the runtime stage, the Dockerfile: +- Installs necessary runtime dependencies like `xvfb`, `libgtk2.0`, `libsqlite3`, and others required to run the FHIR server. +- Creates directories for configuration, package cache, and terminology cache: + - Configuration directory: `/root/fhirserver/config` + - Terminology cache: `/var/cache/txcache` +- Extracts the tarball (`install.tgz`) into `/root/fhirserver/install`. +- Runs the installation script (`install.sh`) to set up the FHIR server environment. +- Exposes port `80` for the FHIR server. + +## Paths + +### 1. **Installation Paths** +The software is installed by default into the following directories: +- **Binary files** (executables): `/root/fhirserver/install/bin/` +- **Libraries**: `/root/fhirserver/install/x86_64/` +- **Configuration files**: `/root/fhirserver/install/config/` +- **Default configuration files**: `/root/fhirserver/install/default_config/` +- **Content files (such as `.properties` and `.dat` files)**: `/root/fhirserver/install/content/` +- **Web assets**: `/root/fhirserver/install/web/` + +### 2. **Cache and Configuration** +- **Terminology cache**: `/var/cache/txcache` + - This directory is used for caching terminology data during FHIR operations. +- **Configuration**: + - The main configuration files for the FHIR server are stored in `/root/fhirserver/install/config/`. If configuration files are not available, default configurations from `/root/fhirserver/install/default_config/` will be used. + +### 3. **Tarball Location** +The final packaged installation tarball is created in `/root/fhirserver/install.tgz`. This tarball contains all the necessary files to deploy and run the FHIR server. + +## Health Check +The Dockerfile includes a health check to verify if the FHIR server is running. It sends a request to `http://localhost:80/fhir/metadata` every minute. If the server fails to respond, the container is considered unhealthy. + +```bash +HEALTHCHECK --interval=1m --timeout=10s --retries=5 \ + CMD curl -f http://localhost:${PORT}/fhir/metadata || exit 1 +``` + + + +## Environment Variables + +- `DISPLAY=:99`: Xvfb is used for the graphical environment. This environment variable sets the display. +- `PORT=80`: The default port for the FHIR server. +- `TERMINOLOGY_CACHE=/var/cache/txcache`: The directory used to cache terminology data during runtime. + +## Installation Process + +The installation is done by running the installer after ensuring the needed permissions are set: + +```bash +RUN chmod a+x ./install.sh && ./install.sh +``` + + +## Usage Instructions + +### Build the Docker Image + +To build the Docker image, use the following command: + +```bash +docker build -t fhirserver-image . +``` + + +### Run the Docker Container + +#### Default configuration +To run the container with the default configuration: + +```bash +docker run -d -p 80:80 --name fhirserver fhirserver-image` +``` +This command will run the FHIR server on port 80 of your host machine. + +#### Customizing Configuration + +You can customize the configuration of the FHIR server by mapping local directory to the respective Docker container directory (`/root/fhirserver/config`). This can be done using Docker volume mapping. + +For example, to override the default configuration by mapping a local folder to the FHIR server's configuration folder: +```yaml +version: '3.3' +services: + fhirserver: + image: zeora/fhirserver:nightly + volumes: + - ./config:/root/fhirserver/config +``` + +You can also map a local terminology cache to `/var/cache/txcache` to persist it between container restarts. + + +### Access the FHIR Server + +Once the container is running, you can access the FHIR server at http://localhost + From dd89c5caacc0ed8f859930674fa4279d44f8cbeb Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Thu, 26 Sep 2024 21:55:49 +0200 Subject: [PATCH 13/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index df0dd56fa..1013bd91e 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -83,4 +83,4 @@ jobs: docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly # Push both tagged images to Docker Hub - docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly + docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly From abdef7f17a3521f2e8bb3e0220d4f349a2bfa2f3 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Thu, 26 Sep 2024 22:13:39 +0200 Subject: [PATCH 14/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index 1013bd91e..e38c57364 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -35,13 +35,9 @@ jobs: -d mysql:8 - name: Docker Build run: | - docker build \ - --tag fhirserver \ - . -# - name: Scan Code -# run: | -# export DISPLAY=0:0 -# docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap + docker build \ + --tag ghcr.io/${{ github.repository_owner }}/fhirserver:nightly . + - name: Prepare ini file env: @@ -76,11 +72,4 @@ jobs: - name: Tag and push Docker image run: | - # Extract the FHIR server version from the library/version.inc file - FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc) - - # Tag the Docker image with the extracted version and "latest" - docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:nightly - - # Push both tagged images to Docker Hub docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly From 2878d2b0a35f34623f3c93fda648456889354ada Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Thu, 26 Sep 2024 23:08:11 +0200 Subject: [PATCH 15/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 46 ++++++++++++++---------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index e38c57364..c43322772 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -1,27 +1,40 @@ +name: Build and Push Docker Image to GHCR + on: - # Trigger the workflow on push or pull request, - # but only for the main branch + # Trigger the workflow on push or pull request for the main branch push: branches: + - main pull_request: + branches: + - main jobs: Build-Docker-Image: runs-on: ubuntu-latest + steps: + # Step 1: Check out the repository code - name: Check out repository code uses: actions/checkout@v2 - - name: Login to Docker Hub + + # Step 2: Log in to GitHub Container Registry (GHCR) + - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub + + # Step 3: Cache terminology files (optional, to avoid re-downloading terminology files) - name: Cache terminology files uses: actions/cache@v2 with: path: ~/terminology key: terminology-${{ github.sha }} restore-keys: terminology- + + # Step 4: Setup MySQL for the build - name: Setup MySQL run: | docker network create gh @@ -33,12 +46,13 @@ jobs: -e MYSQL_PASSWORD=test \ -e MYSQL_DATABASE=test \ -d mysql:8 + + # Step 5: Build the Docker image and tag it for GitHub Container Registry (GHCR) - name: Docker Build run: | - docker build \ - --tag ghcr.io/${{ github.repository_owner }}/fhirserver:nightly . - + docker build --tag ghcr.io/${{ github.repository_owner }}/fhirserver:nightly . + # Step 6: Prepare ini file for your FHIR Server with environment variables - name: Prepare ini file env: FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver @@ -55,21 +69,15 @@ jobs: FHIRSERVER_SSL_PASSWORD: password run: | cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini + + # Step 7: Ensure SNOMED cache is present - name: Ensure SNOMED cache is present run: | mkdir -p ~/terminology/fhir-server wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true - ls ~/terminology/fhir-server/snomed.test.cache - -# - name: Run tests in docker -# run: | -# docker images --all -# docker run \ -# --network gh \ -# -v ~/terminology:/terminology \ -# -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ -# fhirserver -tests + ls ~/terminology/fhir-server/snomed.test.cache - - name: Tag and push Docker image + # Step 8: Push the Docker image to GitHub Container Registry (GHCR) + - name: Push Docker image to GHCR run: | docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly From 25a676440a75a1ccc02921e7702f5d7cc2a3a756 Mon Sep 17 00:00:00 2001 From: Jose Costa Teixeira Date: Thu, 26 Sep 2024 23:14:20 +0200 Subject: [PATCH 16/16] Update linux-docker-build.yml --- .github/workflows/linux-docker-build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index c43322772..514815176 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -3,11 +3,7 @@ name: Build and Push Docker Image to GHCR on: # Trigger the workflow on push or pull request for the main branch push: - branches: - - main pull_request: - branches: - - main jobs: Build-Docker-Image: