diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml
index e2f26081b..514815176 100644
--- a/.github/workflows/linux-docker-build.yml
+++ b/.github/workflows/linux-docker-build.yml
@@ -1,87 +1,79 @@
-on:
- # Trigger the workflow on push or pull request,
- # but only for the main branch
- push:
- branches:
- - master
-# 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
+name: Build and Push Docker Image to GHCR
+
+on:
+ # Trigger the workflow on push or pull request for the main branch
+ push:
+ pull_request:
+
+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
+
+ # Step 2: Log in to GitHub Container Registry (GHCR)
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ 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
+ 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
+
+ # 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 .
+
+ # Step 6: Prepare ini file for your FHIR Server with environment variables
+ - 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
+
+ # 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
+
+ # 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
diff --git a/Dockerfile b/Dockerfile
index c04ad593b..ecb8e0092 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,114 @@ 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
+
+
+# Run the installation script for a blank, clean install
+RUN chmod a+x ./install.sh && ./install.sh
+
+####################################################################
+
+WORKDIR /root/fhirserver
+
+# Define entrypoint and command
+CMD ["bash", "-c", "cd ~/fhirserver/ && ./start.sh"]
+
+# Expose the necessary port
+EXPOSE 80
diff --git a/README-docker.md b/README-docker.md
new file mode 100644
index 000000000..640de6024
--- /dev/null
+++ b/README-docker.md
@@ -0,0 +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
+
+#### 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
+
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 {} \;
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 '{}' +
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
diff --git a/server/endpoint_storage.pas b/server/endpoint_storage.pas
index ddab65195..cf73aca65 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/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
diff --git a/server/fhirserver.lpi b/server/fhirserver.lpi
index 63cbbe41d..4e1b60eb0 100644
--- a/server/fhirserver.lpi
+++ b/server/fhirserver.lpi
@@ -130,7 +130,7 @@