Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…erver into HealthIntersections-master
  • Loading branch information
costateixeira committed Oct 10, 2024
2 parents 89b6475 + bdbcbfd commit 244d427
Show file tree
Hide file tree
Showing 58 changed files with 3,007 additions and 845 deletions.
67 changes: 30 additions & 37 deletions .github/workflows/linux-docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
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:
# pull_request:
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
# -
# name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# 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
Expand All @@ -33,15 +42,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 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 .
# Step 6: Prepare ini file for your FHIR Server with environment variables
- name: Prepare ini file
env:
FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver
Expand All @@ -58,29 +65,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: |
# 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
docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly
14 changes: 1 addition & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
113 changes: 113 additions & 0 deletions README-docker.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion build/linux-fhirserver.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +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 {} \;
find ./exec/64 -type f ! -name "*.*" -exec strip {} \;
4 changes: 2 additions & 2 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
find . -name "*.ppu" -exec rm '{}' +
find . -name "*.o" -exec rm '{}' +
find . -name "*.ppu" -exec rm '{}' +
find . -name "*.o" -exec rm '{}' +
4 changes: 1 addition & 3 deletions dependencies/Indy10/Protocols/IdHL7.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
Original author Grahame Grieve
This code was donated by HL7Connect.com
For more HL7 open source code see
http://www.hl7connect.com/tools
This code was donated by Kestral Computing
This unit implements support for the Standard HL7 minimal Lower Layer
protocol. For further details, consult the HL7 standard (www.hl7.org).
Expand Down
16 changes: 12 additions & 4 deletions exec/pack/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Attempt_to_a_slice_an_element_that_does_not_repeat__from__in_ = Attempt to a sli
Attempt_to_replace_element_name_for_a_nonchoice_type=Attempt to replace element name for a non-choice type
Attempt_to_use_Terminology_server_when_no_Terminology_server_is_available = Attempt to use Terminology server when no Terminology server is available
Attempt_to_use_a_snapshot_on_profile__as__before_it_is_generated = Attempt to use a snapshot on profile ''{0}'' as {1} before it is generated
BINDING_ADDITIONAL = {0} specified in an additional binding
BINDING_ADDITIONAL_D = {0} specified in an additional binding
BINDING_ADDITIONAL_UC = {0} specified in an additional binding which applies because {1}
BINDING_ADDITIONAL_USAGE = {0} = {1}
BINDING_MAX = {0} specified in the max binding
BUNDLE_BUNDLE_ENTRY_FOUND_MULTIPLE = Found {0} matches for ''{1}'' in the bundle ({2})
BUNDLE_BUNDLE_ENTRY_FOUND_MULTIPLE_FRAGMENT = Found {0} matches for fragment {2} in resource ''{1}'' in the bundle ({3})
Expand Down Expand Up @@ -1029,7 +1031,7 @@ VALUESET_SUPPLEMENT_MISSING_one = Required supplement not found: {1}
VALUESET_SUPPLEMENT_MISSING_other = Required supplements not found: {1}
VALUESET_TOO_COSTLY = The value set ''{0}'' expansion has too many codes to display ({1})
VALUESET_TOO_COSTLY_COUNT = The value set ''{0}'' expansion has {2} codes, which is too many to display ({1})
VALUESET_TOO_COSTLY_TIME = The value set ''{0}'' expansion took too long to process (>{1}sec)
VALUESET_TOO_COSTLY_TIME = The value set ''{0}'' {2} took too long to process (>{1}sec)
VALUESET_UNC_SYSTEM_WARNING = Unknown System ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1})
VALUESET_UNC_SYSTEM_WARNING_VER = Unknown System/Version ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1})
VALUESET_UNKNOWN_FILTER_PROPERTY = The property ''{0}'' is not known for the system ''{1}'', so may not be understood by the terminology ecosystem. Known properties for this system: {2}
Expand Down Expand Up @@ -1138,6 +1140,12 @@ TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF = Hyperlink scheme ''{3}'' in ''{0}''
SM_TARGET_TYPE_UNKNOWN = The type of the target variable is not known: {0}
XHTML_XHTML_ATTRIBUTE_XML_SPACE = The attribute 'xml:space' is legal but has a fixed value of 'preserve'. It''s use is discouraged
VALIDATION_HL7_PUBLISHER_MULTIPLE_WGS = This resource has more than workgroup extension (http://hl7.org/fhir/StructureDefinition/structuredefinition-wg)
NO_VALID_DISPLAY_FOUND_NONE_FOR_LANG = Wrong Display Name ''{0}'' for {1}#{2}. There are no valid display names found for language(s) ''{3}''. Default display is ''{4}''
NO_VALID_DISPLAY_FOUND_NONE_FOR_LANG_OK = There are no valid display names found for the code {1}#{2} for language(s) ''{3}''. The display is ''{4}'' the default language display
NO_VALID_DISPLAY_FOUND_NONE_FOR_LANG_ERR = Wrong Display Name ''{0}'' for {1}#{2}. There are no valid display names found for language(s) ''{3}''. Default display is ''{4}''
NO_VALID_DISPLAY_AT_ALL = Cannot validate display Name ''{0}'' for {1}#{2}: No displays are known

SD_BASE_EXPERIMENTAL = The definition builds on ''{0}'' which is experimental, but this definition is not labeled as experimental
SD_ED_EXPERIMENTAL_BINDING = The definition for the element ''{0}'' binds to the value set ''{1}'' which is experimental, but this structure is not labeled as experimental
VALIDATION_NO_EXPERIMENTAL_CONTENT = Experimental content is not allowed in this context
SD_ED_ADDITIONAL_BINDING_USAGE_UNKNOWN = The Usage Context {0}#{1} is not recognised and may not be correct
SD_ED_ADDITIONAL_BINDING_USAGE_INVALID_ELEMENT = The Usage Context {0}#{1} is a reference to an element that does not exist
SD_ED_ADDITIONAL_BINDING_USAGE_INVALID_TYPE = The Usage Context value must be of type {1} not {0}
Loading

0 comments on commit 244d427

Please sign in to comment.