diff --git a/.dockerignore b/.dockerignore
index 4965947b8..05de44a5d 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -3,3 +3,4 @@
**/node_modules/
**/node
*.iml
+.idea/
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 4160b49b5..e583eec3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
**/target/
**/.DS_Store
**/node_modules/
+.idea/
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..0f4a4f900
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,28 @@
+# syntax=docker/dockerfile:1
+
+### Dev Stage
+FROM openmrs/openmrs-core:dev as dev
+WORKDIR /app
+
+ENV MVN_ARGS_SETTINGS="-s /usr/share/maven/ref/settings-docker.xml"
+ENV MVN_ARGS="install"
+
+# Copy build files
+COPY pom.xml ./
+COPY distro ./distro/
+
+# Build the distro
+RUN mvn $MVN_ARGS_SETTINGS $MVN_ARGS
+
+### Run Stage
+# Replace 'nightly' with the exact version of openmrs-core built for production (if available)
+FROM openmrs/openmrs-core:nightly
+
+# Do not copy the war if using the correct openmrs-core image version
+COPY --from=dev /app/distro/target/sdk-distro/web/openmrs.war /openmrs/distribution/openmrs_core
+
+COPY --from=dev /app/distro/target/sdk-distro/web/openmrs-distro.properties /openmrs/distribution
+
+COPY --from=dev /app/distro/target/sdk-distro/web/modules /openmrs/distribution/openmrs_modules
+COPY --from=dev /app/distro/target/sdk-distro/web/owa /openmrs/distribution/openmrs_owas
+COPY --from=dev /app/distro/target/referenceapplication-distro/openmrs_config /openmrs/distribution/openmrs_config
diff --git a/Dockerfile.build b/Dockerfile.build
deleted file mode 100644
index e7cc68037..000000000
--- a/Dockerfile.build
+++ /dev/null
@@ -1,25 +0,0 @@
-# syntax=docker/dockerfile:1.3
-FROM maven:3-eclipse-temurin-11 AS mvn-builder
-RUN mkdir -p /openmrs
-WORKDIR /openmrs
-COPY pom.xml .
-COPY distro ./distro
-RUN mvn clean install
-
-FROM node:lts-alpine as npm-builder
-ARG APP_SHELL_VERSION=next
-RUN mkdir -p /openmrs
-WORKDIR /openmrs
-COPY spa-build-config.json .
-RUN npx openmrs@$APP_SHELL_VERSION build --build-config spa-build-config.json --target ./spa
-RUN npx openmrs@$APP_SHELL_VERSION assemble --mode config --config spa-build-config.json --target ./spa
-
-FROM alpine:latest AS unpacker
-RUN mkdir -p /openmrs
-WORKDIR /openmrs
-COPY --from=mvn-builder /openmrs/distro/target/referenceapplication-distro-*.tar.gz ./
-RUN tar -xzf referenceapplication-distro-*.tar.gz && rm referenceapplication-distro-*.tar.gz
-COPY --from=npm-builder /openmrs/spa /openmrs/spa
-
-FROM scratch as distro
-COPY --from=unpacker /openmrs /openmrs
diff --git a/README.md b/README.md
index d036f2338..300764892 100644
--- a/README.md
+++ b/README.md
@@ -3,23 +3,14 @@
#### Package the distribution and prepare the run
```
-mvn clean package
+docker-compose build
```
#### Run the app
```
-cd run/docker
docker-compose up
```
New OpenMRS UI is accessible at http://localhost/openmrs/spa
OpenMRS Legacy UI is accessible at http://localhost/openmrs
-
----
-
-## Notes
-
-`package/` Package the OpenMRS distribution with the specified dependencies (omod, frontend modules, configurations...). See [package/README.md](distro/README.md) for more info.
-
-`run/` Run the OpenMRS distribution. Currently, this only supports Docker. See [run/README.md](run/README.md) for more info.
diff --git a/build.sh b/build.sh
deleted file mode 100755
index a82b377ea..000000000
--- a/build.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env sh
-set -eu
-
-help() {
- echo "Script to build the RefApp distribution"
- echo "Usage: $(basename "$0") [options]"
- printf "\t-h print this help message\n"
- printf "\t-T run this build with the given target. Should be one of \"base\" or \"embedded\"\n"
-}
-
-echoerr() {
- echo "$@" 1>&2
-}
-
-TARGET=embedded
-APP_SHELL_VERSION=3.1.1-pre.188
-
-while getopts "h:T:a:" opt; do
- case $opt in
- h) help;exit 0;;
- T) TARGET=$OPTARG;;
- a) APP_SHELL_VERSION=$OPTARG;;
- *) echoerr "[ERROR] Unrecognized option $opt"; help; exit 1;;
- esac
-done
-
-docker build -f Dockerfile.build --tag openmrs/3-reference-distro:latest --target distro .
-docker build -f docker/backend/Dockerfile --tag openmrs/openmrs-reference-application-3-backend:latest --target "$TARGET" docker/backend
-docker build -f docker/frontend/Dockerfile --tag openmrs/openmrs-reference-application-3-frontend:latest --target "$TARGET" --build-arg APP_SHELL_VERSION="$APP_SHELL_VERSION" docker/frontend
-docker build -f docker/gateway/Dockerfile --tag openmrs/openmrs-reference-application-3-gateway:latest docker/gateway
diff --git a/distro/distro.properties b/distro/distro.properties
index e37488a77..95dd3d1c2 100644
--- a/distro/distro.properties
+++ b/distro/distro.properties
@@ -1,5 +1,5 @@
name=Ref 3.x distro
-version=1.0
+version=3.0.0
war.openmrs=${openmrs.version}
omod.initializer=${initializer.version}
omod.fhir2=${fhir2.version}
diff --git a/distro/pom.xml b/distro/pom.xml
index 98b687a33..199913c10 100644
--- a/distro/pom.xml
+++ b/distro/pom.xml
@@ -41,7 +41,7 @@
1.4.0
3.0.0-SNAPSHOT
1.25.0-SNAPSHOT
- 1.13.0
+ 1.14.0-SNAPSHOT
1.3.0
1.10.0
diff --git a/docker/docker-compose.yml b/docker-compose.yml
similarity index 78%
rename from docker/docker-compose.yml
rename to docker-compose.yml
index f2f060693..149d8bccc 100644
--- a/docker/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,8 +1,8 @@
version: "3.7"
services:
- # Gateway
gateway:
+ image: openmrs/openmrs-reference-application-3-gateway:${TAG:-nightly}
build:
context: ./gateway
depends_on:
@@ -11,11 +11,10 @@ services:
ports:
- 80:80
- # Frontend
frontend:
+ image: openmrs/openmrs-reference-application-3-frontend:${TAG:-nightly}
build:
context: ./frontend
- target: ${target:-base}
environment:
SPA_PATH: /openmrs/spa
API_URL: /openmrs
@@ -23,14 +22,11 @@ services:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
timeout: 5s
- volumes:
- - ./distro/spa:/usr/share/nginx/html/
- # OpenMRS:
backend:
+ image: openmrs/openmrs-reference-application-3-backend:${TAG:-nightly}
build:
- context: backend
- target: ${target:-base}
+ context: .
depends_on:
- db
environment:
@@ -46,9 +42,6 @@ services:
timeout: 5s
volumes:
- openmrs-data:/openmrs/data
- - ./distro/openmrs_core/:/openmrs/distribution/openmrs_core/
- - ./distro/openmrs_modules:/openmrs/distribution/openmrs_modules/
- - ./distro/openmrs_config:/openmrs/distribution/openmrs_config/
# MariaDB
db:
diff --git a/docker/.env b/docker/.env
deleted file mode 100644
index 8aac4ec52..000000000
--- a/docker/.env
+++ /dev/null
@@ -1,8 +0,0 @@
-# OpenMRS
-OPENMRS_DB_USER=openmrs
-OPENMRS_DB_PASSWORD=password
-OPENMRS_USER=admin
-OPENMRS_PASSWORD=Admin123
-
-# MySQL
-MYSQL_ROOT_PASSWORD=iOfFhmqiim
diff --git a/docker/backend/.dockerignore b/docker/backend/.dockerignore
deleted file mode 100644
index 3e17be888..000000000
--- a/docker/backend/.dockerignore
+++ /dev/null
@@ -1 +0,0 @@
-spa/
diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile
deleted file mode 100644
index 11baaf347..000000000
--- a/docker/backend/Dockerfile
+++ /dev/null
@@ -1,75 +0,0 @@
-# syntax=docker/dockerfile:1
-FROM tomcat:7-jdk8-adoptopenjdk-hotspot as base
-
-# All environment variables that are available to configure on this container are listed here
-# for clarity. These list the variables supported, and the default values if not overridden
-
-# These environment variables are appended to configure the Tomcat JAVA_OPTS
-ENV OMRS_JAVA_MEMORY_OPTS="-XX:NewSize=128m"
-ENV OMRS_JAVA_SERVER_OPTS="-Dfile.encoding=UTF-8 -server -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Djava.awt.headlesslib=true"
-
-# These environment variables are used to create the openmrs-server.properties file, which controls how OpenMRS initializes
-ENV OMRS_CONFIG_ADD_DEMO_DATA="false"
-ENV OMRS_CONFIG_ADMIN_USER_PASSWORD="Admin123"
-ENV OMRS_CONFIG_AUTO_UPDATE_DATABASE="true"
-ENV OMRS_CONFIG_CREATE_DATABASE_USER="false"
-ENV OMRS_CONFIG_CREATE_TABLES="false"
-ENV OMRS_CONFIG_HAS_CURRENT_OPENMRS_DATABASE="true"
-ENV OMRS_CONFIG_INSTALL_METHOD="auto"
-ENV OMRS_CONFIG_MODULE_WEB_ADMIN="true"
-
-# These variables are specific to database connections
-# Supported values for OMRS_CONFIG_CONNECTION_TYPE are "mysql" and "postgresql"
-# other values are treated as MySQL
-ENV OMRS_CONFIG_CONNECTION_TYPE="mysql"
-ENV OMRS_CONFIG_CONNECTION_USERNAME="openmrs"
-ENV OMRS_CONFIG_CONNECTION_PASSWORD="openmrs"
-ENV OMRS_CONFIG_CONNECTION_SERVER="localhost"
-ENV OMRS_CONFIG_CONNECTION_DATABASE="openmrs"
-
-# These environment variables can be used to customise the database connection.
-# Their default values depend on which database you are using.
-# OMRS_CONFIG_CONNECTION_DRIVER_CLASS
-# OMRS_CONFIG_CONNECTION_PORT
-# OMRS_CONFIG_CONNECTION_ARGS
-# OMRS_CONFIG_CONNECTION_EXTRA_ARGS
-#
-# If you really need complete control, you can just set
-# OMRS_CONFIG_CONNECTION_URL to whatever the URL should be
-
-# These environment variables are meant to enable developer settings
-# OMRS_DEV_DEBUG_PORT
-
-# Additional environment variables as needed. This should match the name of the distribution supplied OpenMRS war file
-ENV OMRS_WEBAPP_NAME="openmrs"
-
-# /openmrs/distribution is expected to be mounted into the container with the artifacts making up the distribution
-# /openmrs/data represents the data persisted inside the container to the filesystem for OpenMRS
-
-# Take some initial steps to improve overall security, size, and functionality of the container
-# This includes updating packages and removing all of the default Tomcat webapps
-RUN sed -i '/Connector port="8080"/a URIEncoding="UTF-8" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"' /usr/local/tomcat/conf/server.xml
-
-# This is run at the end primarily so that all the previous steps in building the image remain cacheable
-RUN apt-get update && apt-get install -y \
- zip dumb-init \
- && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
- && rm -rf /usr/local/tomcat/webapps/*
-
-# Copy in the start-up scripts
-COPY wait-for-it.sh /usr/local/tomcat/wait-for-it.sh
-COPY startup.sh /usr/local/tomcat/startup.sh
-RUN chmod +x /usr/local/tomcat/wait-for-it.sh
-RUN chmod +x /usr/local/tomcat/startup.sh
-
-# Add Dockerfile and commit info for documentation
-COPY Dockerfile /openmrs/docker
-
-EXPOSE 8080
-
-CMD ["dumb-init", "/usr/local/tomcat/startup.sh"]
-
-FROM base AS embedded
-COPY --from=openmrs/3-reference-distro:latest /openmrs/openmrs_config /openmrs/distribution/openmrs_config
-COPY --from=openmrs/3-reference-distro:latest /openmrs/openmrs_core /openmrs/distribution/openmrs_core
-COPY --from=openmrs/3-reference-distro:latest /openmrs/openmrs_modules /openmrs/distribution/openmrs_modules
diff --git a/docker/backend/startup.sh b/docker/backend/startup.sh
deleted file mode 100644
index 287ee21ef..000000000
--- a/docker/backend/startup.sh
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/bin/bash -eu
-
-echo "Initiating OpenMRS startup"
-
-# This startup script is responsible for fully preparing the OpenMRS Tomcat environment.
-
-OMRS_HOME="/openmrs"
-OMRS_WEBAPP_NAME=${OMRS_WEBAPP_NAME:-openmrs}
-
-# A volume mount is expected that contains distribution artifacts. The expected format is shown in these environment vars.
-
-OMRS_DISTRO_DIR="$OMRS_HOME/distribution"
-OMRS_DISTRO_CORE="$OMRS_DISTRO_DIR/openmrs_core"
-OMRS_DISTRO_MODULES="$OMRS_DISTRO_DIR/openmrs_modules"
-OMRS_DISTRO_OWAS="$OMRS_DISTRO_DIR/openmrs_owas"
-OMRS_DISTRO_CONFIG="$OMRS_DISTRO_DIR/openmrs_config"
-
-# Each of these mounted directories are used to populate expected configurations on the server, defined here
-
-OMRS_DATA_DIR="$OMRS_HOME/data"
-OMRS_MODULES_DIR="$OMRS_DATA_DIR/modules"
-OMRS_OWA_DIR="$OMRS_DATA_DIR/owa"
-OMRS_CONFIG_DIR="$OMRS_DATA_DIR/configuration"
-
-OMRS_SERVER_PROPERTIES_FILE="$OMRS_HOME/$OMRS_WEBAPP_NAME-server.properties"
-OMRS_RUNTIME_PROPERTIES_FILE="$OMRS_DATA_DIR/$OMRS_WEBAPP_NAME-runtime.properties"
-
-TOMCAT_DIR="/usr/local/tomcat"
-TOMCAT_WEBAPPS_DIR="$TOMCAT_DIR/webapps"
-TOMCAT_WORK_DIR="$TOMCAT_DIR/work"
-TOMCAT_TEMP_DIR="$TOMCAT_DIR/temp"
-TOMCAT_SETENV_FILE="$TOMCAT_DIR/bin/setenv.sh"
-
-echo "Clearing out existing directories of any previous artifacts"
-
-rm -fR $TOMCAT_WEBAPPS_DIR;
-rm -fR $OMRS_MODULES_DIR;
-rm -fR $OMRS_OWA_DIR
-rm -fR $OMRS_CONFIG_DIR
-rm -fR $TOMCAT_WORK_DIR
-rm -fR $TOMCAT_TEMP_DIR
-
-mkdir -p $TOMCAT_TEMP_DIR
-
-echo "Loading artifacts into appropriate locations"
-
-cp -r $OMRS_DISTRO_CORE $TOMCAT_WEBAPPS_DIR
-[ -d "$OMRS_DISTRO_MODULES" ] && cp -r $OMRS_DISTRO_MODULES $OMRS_MODULES_DIR
-[ -d "$OMRS_DISTRO_OWAS" ] && cp -r $OMRS_DISTRO_OWAS $OMRS_OWA_DIR
-[ -d "$OMRS_DISTRO_CONFIG" ] && cp -r $OMRS_DISTRO_CONFIG $OMRS_CONFIG_DIR
-
-# setup database configuration properties
-# Setup database configuration properties
-OMRS_CONFIG_DATABASE="${OMRS_CONFIG_DATABASE:-mysql}"
-OMRS_CONFIG_CONNECTION_SERVER="${OMRS_CONFIG_CONNECTION_SERVER:-localhost}"
-OMRS_CONFIG_CONNECTION_DATABASE="${OMRS_CONFIG_CONNECTION_DATABASE:-openmrs}"
-OMRS_CONFIG_CONNECTION_EXTRA_ARGS="${OMRS_CONFIG_CONNECTION_EXTRA_ARGS-}"
-
-if [[ -z $OMRS_CONFIG_DATABASE || "$OMRS_CONFIG_DATABASE" == "mysql" ]]; then
- OMRS_CONFIG_JDBC_URL_PROTOCOL=mysql
- OMRS_CONFIG_CONNECTION_DRIVER_CLASS="${OMRS_CONFIG_CONNECTION_DRIVER_CLASS:-com.mysql.jdbc.Driver}"
- OMRS_CONFIG_CONNECTION_PORT="${OMRS_CONFIG_CONNECTION_PORT:-3306}"
- OMRS_CONFIG_CONNECTION_ARGS="${OMRS_CONFIG_CONNECTION_ARGS:-?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8}"
-elif [[ "$OMRS_CONFIG_DATABASE" == "postgresql" ]]; then
- OMRS_CONFIG_JDBC_URL_PROTOCOL=postgresql
- OMRS_CONFIG_CONNECTION_DRIVER_CLASS="${OMRS_CONFIG_CONNECTION_DRIVER_CLASS:-org.postgresql.Driver}"
- OMRS_CONFIG_CONNECTION_PORT="${OMRS_CONFIG_CONNECTION_PORT:-5432}"
-else
- echo "Unknown database type $OMRS_CONFIG_DATABASE. Using properties for MySQL"
- OMRS_CONFIG_JDBC_URL_PROTOCOL=mysql
- OMRS_CONFIG_CONNECTION_DRIVER_CLASS="${OMRS_CONFIG_CONNECTION_DRIVER_CLASS:-com.mysql.jdbc.Driver}"
- OMRS_CONFIG_CONNECTION_PORT="${OMRS_CONFIG_CONNECTION_PORT:-3306}"
- OMRS_CONFIG_CONNECTION_ARGS="${OMRS_CONFIG_CONNECTION_ARGS:-?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8}"
-fi
-
-# Build the JDBC URL using the above properties
-OMRS_CONFIG_CONNECTION_URL="${OMRS_CONFIG_CONNECTION_URL:-jdbc:${OMRS_CONFIG_JDBC_URL_PROTOCOL}://${OMRS_CONFIG_CONNECTION_SERVER}:${OMRS_CONFIG_CONNECTION_PORT}/${OMRS_CONFIG_CONNECTION_DATABASE}${OMRS_CONFIG_CONNECTION_ARGS}${OMRS_CONFIG_CONNECTION_EXTRA_ARGS}}"
-
-echo "Writing out $OMRS_SERVER_PROPERTIES_FILE"
-
-cat > $OMRS_SERVER_PROPERTIES_FILE << EOF
-add_demo_data=${OMRS_CONFIG_ADD_DEMO_DATA}
-admin_user_password=${OMRS_CONFIG_ADMIN_USER_PASSWORD}
-auto_update_database=${OMRS_CONFIG_AUTO_UPDATE_DATABASE}
-connection.driver_class=${OMRS_CONFIG_CONNECTION_DRIVER_CLASS}
-connection.username=${OMRS_CONFIG_CONNECTION_USERNAME}
-connection.password=${OMRS_CONFIG_CONNECTION_PASSWORD}
-connection.url=${OMRS_CONFIG_CONNECTION_URL}
-create_database_user=${OMRS_CONFIG_CREATE_DATABASE_USER}
-create_tables=${OMRS_CONFIG_CREATE_TABLES}
-has_current_openmrs_database=${OMRS_CONFIG_HAS_CURRENT_OPENMRS_DATABASE}
-install_method=${OMRS_CONFIG_INSTALL_METHOD}
-module_web_admin=${OMRS_CONFIG_MODULE_WEB_ADMIN}
-module.allow_web_admin=${OMRS_CONFIG_MODULE_WEB_ADMIN}
-EOF
-
-if [ -f $OMRS_RUNTIME_PROPERTIES_FILE ]; then
- echo "Found existing runtime properties file at $OMRS_RUNTIME_PROPERTIES_FILE. Overwriting with $OMRS_SERVER_PROPERTIES_FILE"
- cp $OMRS_SERVER_PROPERTIES_FILE $OMRS_RUNTIME_PROPERTIES_FILE
-fi
-
-echo "Writing out $TOMCAT_SETENV_FILE file"
-
-JAVA_OPTS="$OMRS_JAVA_SERVER_OPTS"
-CATALINA_OPTS="$OMRS_JAVA_MEMORY_OPTS -DOPENMRS_INSTALLATION_SCRIPT=$OMRS_SERVER_PROPERTIES_FILE -DOPENMRS_APPLICATION_DATA_DIRECTORY=$OMRS_DATA_DIR/"
-
-if [ -n "${OMRS_DEV_DEBUG_PORT-}" ]; then
- echo "Enabling debugging on port $OMRS_DEV_DEBUG_PORT"
- CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$OMRS_DEV_DEBUG_PORT"
-fi
-
-cat > $TOMCAT_SETENV_FILE << EOF
-export JAVA_OPTS="$JAVA_OPTS"
-export CATALINA_OPTS="$CATALINA_OPTS"
-EOF
-
-echo "Waiting for database to initialize..."
-
-/usr/local/tomcat/wait-for-it.sh --timeout=3600 "${OMRS_CONFIG_CONNECTION_SERVER}:${OMRS_CONFIG_CONNECTION_PORT}"
-
-echo "Starting up OpenMRS..."
-
-/usr/local/tomcat/bin/catalina.sh run &
-
-# Trigger first filter to start data importation
-sleep 15
-curl -sL "http://localhost:8080/$OMRS_WEBAPP_NAME/" > /dev/null
-sleep 15
-
-# bring tomcat process to foreground again
-wait ${!}
diff --git a/docker/backend/wait-for-it.sh b/docker/backend/wait-for-it.sh
deleted file mode 100644
index e4f141f0a..000000000
--- a/docker/backend/wait-for-it.sh
+++ /dev/null
@@ -1,203 +0,0 @@
-#!/usr/bin/env bash
-# Use this script to test if a given TCP host/port are available
-
-# The MIT License (MIT)
-# Copyright (c) 2016 Giles Hall
-
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is furnished to do
-# so, subject to the following conditions:
-
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
- cat << USAGE >&2
-Usage:
- $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
- -h HOST | --host=HOST Host or IP under test
- -p PORT | --port=PORT TCP port under test
- Alternatively, you specify the host and port as host:port
- -s | --strict Only execute subcommand if the test succeeds
- -q | --quiet Don't output any status messages
- -t TIMEOUT | --timeout=TIMEOUT
- Timeout in seconds, zero for no timeout
- -- COMMAND ARGS Execute command with args after the test finishes
-USAGE
- exit 1
-}
-
-wait_for()
-{
- if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
- echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
- else
- echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
- fi
- WAITFORIT_start_ts=$(date +%s)
- while :
- do
- if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
- nc -z $WAITFORIT_HOST $WAITFORIT_PORT
- WAITFORIT_result=$?
- else
- (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
- WAITFORIT_result=$?
- fi
- if [[ $WAITFORIT_result -eq 0 ]]; then
- WAITFORIT_end_ts=$(date +%s)
- echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
- break
- fi
- sleep 1
- done
- return $WAITFORIT_result
-}
-
-wait_for_wrapper()
-{
- # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
- if [[ $WAITFORIT_QUIET -eq 1 ]]; then
- timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
- else
- timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
- fi
- WAITFORIT_PID=$!
- trap "kill -INT -$WAITFORIT_PID" INT
- wait $WAITFORIT_PID
- WAITFORIT_RESULT=$?
- if [[ $WAITFORIT_RESULT -ne 0 ]]; then
- echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
- fi
- return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
- case "$1" in
- *:* )
- WAITFORIT_hostport=(${1//:/ })
- WAITFORIT_HOST=${WAITFORIT_hostport[0]}
- WAITFORIT_PORT=${WAITFORIT_hostport[1]}
- shift 1
- ;;
- --child)
- WAITFORIT_CHILD=1
- shift 1
- ;;
- -q | --quiet)
- WAITFORIT_QUIET=1
- shift 1
- ;;
- -s | --strict)
- WAITFORIT_STRICT=1
- shift 1
- ;;
- -h)
- WAITFORIT_HOST="$2"
- if [[ $WAITFORIT_HOST == "" ]]; then break; fi
- shift 2
- ;;
- --host=*)
- WAITFORIT_HOST="${1#*=}"
- shift 1
- ;;
- -p)
- WAITFORIT_PORT="$2"
- if [[ $WAITFORIT_PORT == "" ]]; then break; fi
- shift 2
- ;;
- --port=*)
- WAITFORIT_PORT="${1#*=}"
- shift 1
- ;;
- -t)
- WAITFORIT_TIMEOUT="$2"
- if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
- shift 2
- ;;
- --timeout=*)
- WAITFORIT_TIMEOUT="${1#*=}"
- shift 1
- ;;
- --)
- shift
- WAITFORIT_CLI=("$@")
- break
- ;;
- --help)
- usage
- ;;
- *)
- echoerr "Unknown argument: $1"
- usage
- ;;
- esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
- echoerr "Error: you need to provide a host and port to test."
- usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# Check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-
-WAITFORIT_BUSYTIMEFLAG=""
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
- WAITFORIT_ISBUSY=1
- # Check if busybox timeout uses -t flag
- # (recent Alpine versions don't support -t anymore)
- if timeout &>/dev/stdout | grep -q -e '-t '; then
- WAITFORIT_BUSYTIMEFLAG="-t"
- fi
-else
- WAITFORIT_ISBUSY=0
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
- wait_for
- WAITFORIT_RESULT=$?
- exit $WAITFORIT_RESULT
-else
- if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
- wait_for_wrapper
- WAITFORIT_RESULT=$?
- else
- wait_for
- WAITFORIT_RESULT=$?
- fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
- if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
- echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
- exit $WAITFORIT_RESULT
- fi
- exec "${WAITFORIT_CLI[@]}"
-else
- exit $WAITFORIT_RESULT
-fi
diff --git a/docker/docker-compose-distro.yml b/docker/docker-compose-distro.yml
deleted file mode 100644
index 97aedf9d8..000000000
--- a/docker/docker-compose-distro.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-version: "3.7"
-
-services:
- # Proxy
- proxy:
- image: openmrs/openmrs-reference-application-3-gateway:latest
- depends_on:
- - frontend
- - backend
- ports:
- - "80:80"
-
- # Frontend
- frontend:
- image: openmrs/openmrs-reference-application-3-frontend:latest
- environment:
- SPA_PATH: /openmrs/spa
- API_URL: /openmrs
- SPA_CONFIG_URLS:
- healthcheck:
- test: ["CMD", "curl", "-f", "http://localhost/"]
- timeout: 5s
-
- # OpenMRS:
- backend:
- image: openmrs/openmrs-reference-application-3-backend:latest
- depends_on:
- - db
- environment:
- OMRS_CONFIG_MODULE_WEB_ADMIN: "true"
- OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true"
- OMRS_CONFIG_CREATE_TABLES: "true"
- OMRS_CONFIG_CONNECTION_SERVER: db
- OMRS_CONFIG_CONNECTION_DATABASE: openmrs
- OMRS_CONFIG_CONNECTION_USERNAME: ${OPENMRS_DB_USER:-openmrs}
- OMRS_CONFIG_CONNECTION_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs}
- healthcheck:
- test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs"]
- timeout: 5s
- volumes:
- - openmrs-data:/openmrs/data
-
- # MariaDB
- db:
- image: mariadb:10.8.2
- command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci"
- environment:
- MYSQL_DATABASE: openmrs
- MYSQL_USER: ${OPENMRS_DB_USER:-openmrs}
- MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs}
- MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-openmrs}
- volumes:
- - db-data:/var/lib/mysql
-
-volumes:
- openmrs-data: ~
- db-data: ~
diff --git a/docker/frontend/Dockerfile b/frontend/Dockerfile
similarity index 51%
rename from docker/frontend/Dockerfile
rename to frontend/Dockerfile
index 0ecd20d4b..57c5938d4 100644
--- a/docker/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -1,5 +1,13 @@
# syntax=docker/dockerfile:1.3
-FROM nginx:1.21-alpine AS base
+FROM node:lts-alpine as dev
+ARG APP_SHELL_VERSION=next
+RUN mkdir -p /app
+WORKDIR /app
+COPY spa-build-config.json .
+RUN npx openmrs@$APP_SHELL_VERSION build --build-config spa-build-config.json --target ./spa
+RUN npx openmrs@$APP_SHELL_VERSION assemble --mode config --config spa-build-config.json --target ./spa
+
+FROM nginx:1.21-alpine
RUN apk update && \
apk upgrade && \
@@ -14,7 +22,6 @@ RUN chmod +x /usr/local/bin/startup.sh
COPY nginx.conf /etc/nginx/nginx.conf
-CMD ["/usr/local/bin/startup.sh"]
+COPY --from=dev /app/spa /usr/share/nginx/html
-FROM base AS embedded
-COPY --from=openmrs/3-reference-distro:latest /openmrs/spa /usr/share/nginx/html
+CMD ["/usr/local/bin/startup.sh"]
diff --git a/docker/frontend/nginx.conf b/frontend/nginx.conf
similarity index 100%
rename from docker/frontend/nginx.conf
rename to frontend/nginx.conf
diff --git a/spa-build-config.json b/frontend/spa-build-config.json
similarity index 100%
rename from spa-build-config.json
rename to frontend/spa-build-config.json
diff --git a/docker/frontend/startup.sh b/frontend/startup.sh
similarity index 100%
rename from docker/frontend/startup.sh
rename to frontend/startup.sh
diff --git a/docker/gateway/Dockerfile b/gateway/Dockerfile
similarity index 100%
rename from docker/gateway/Dockerfile
rename to gateway/Dockerfile
diff --git a/docker/gateway/nginx.conf b/gateway/nginx.conf
similarity index 96%
rename from docker/gateway/nginx.conf
rename to gateway/nginx.conf
index bf66ae94e..2cde2ecd2 100644
--- a/docker/gateway/nginx.conf
+++ b/gateway/nginx.conf
@@ -65,11 +65,11 @@ http {
application/xml;
location /openmrs/spa {
- proxy_pass http://frontend/;
+ proxy_pass http://frontend;
}
location /openmrs {
- proxy_pass http://openmrs:8080;
+ proxy_pass http://backend:8080;
}
location = / {