Skip to content

Commit

Permalink
Squashed commit: Added .devcontainer
Browse files Browse the repository at this point in the history
commit 59eeb01ab63b0d6cca0abf65030ef596dd58dbd4
Author: ChitrankDave <[email protected]>
Date:   Tue Jun 11 09:59:21 2024 -0400

    updated dev-container commands

    - make: support multiple commands as args. e.g. $make clean install log
    - server: updated to kill last running java process to avoid memory leaks.

commit b22d7bad5e9c5ea1cbbcc55f64a103c126ea4a3f
Author: ChitrankDave <[email protected]>
Date:   Mon Jun 3 10:49:08 2024 -0400

    added/updated utility commands

    * make - introduced "install" option to stopTomcat-Build-startTomcat flow; eliminating Community-Connector dependency.

    * server -  Added a server management script for starting (start), stopping (stop), and viewing server logs (log) (catalina.out).

commit 0c4aa972462f8045ce4629bc10837cab33577ad1
Author: ChitrankDave <[email protected]>
Date:   Mon Jun 3 10:33:01 2024 -0400

    Update docker-compose.yml

    Replaced .m2-volume with the local .m2 directory

commit c26bf1b0434b3563e38a7035f96d265b73243942
Author: ChitrankDave <[email protected]>
Date:   Fri May 31 11:15:53 2024 -0400

    Added README.md file for Dev-Container

    Also, changed the name of Dev-container in devcontainer.json

commit 8738883bcad15781d6b3ebc902ee897602f4af57
Author: ChitrankDave <[email protected]>
Date:   Thu May 30 10:40:54 2024 -0400

    Fixes for Windows compatibility

    Added permissions to scripts, and used dos2unix to convert scripts for Windows compatibility.

commit 6524f23c24a3fe32cc2be86a6d6fff141962d269
Author: ChitrankDave <[email protected]>
Date:   Wed May 29 15:23:15 2024 -0400

    Automated scripts for permissions

commit f3938e9eaae4a61b8ab40d713d5e9af66fe0b110
Author: KeisukeKurosaki <[email protected]>
Date:   Wed May 29 13:55:30 2024 -0500

    Windows Changes

    Changed files to accommodate windows changes for the dev environment.

commit 40ae1438ce3ad5331eb5ae4018d40fcf50baa26f
Author: ChitrankDave <[email protected]>
Date:   Tue May 28 11:59:00 2024 -0400

    Create .gitattributes

commit c0601e3380a966543fcd9e7467cf9838bf6dc557
Author: ChitrankDave <[email protected]>
Date:   Mon May 27 16:02:47 2024 -0400

    feat: add devcontainer for development environment

    This commit adds a devcontainer configuration to the repository, providing a convenient and consistent development environment for contributors.
  • Loading branch information
chitrankd authored and Wrekky committed Aug 13, 2024
1 parent 9224f4d commit 649f737
Show file tree
Hide file tree
Showing 16 changed files with 1,938 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Open-OSP EMR DEVCONTAINER Environment Setup

This document outlines the steps for setting up your development environment for the Open-OSP EMR project using Docker
and VS-Code.

## Prerequisites

* **Docker Desktop:** Installed and running
* **VS Code:** Installed with the "Dev Containers" extension
* Install "Dev Containers" Extension: Open VS Code, click on the Extensions icon (four squares in the left sidebar),
search for "Dev Containers" by Microsoft and click "Install".
* **Git:** Installed

## Steps

1. **Clone the repository if not already done:**
```bash
git clone https://github.com/MagentaHealth/open-osp.git
cd open-osp
```

2. **Confirm port availability:**
Before proceeding, ensure that no other processes (Tomcat, MySQL) are using ports 8080 and 3306 on your PC/Macbook.
Also, ensure that no other docker containers are running on those ports.

3. **Open the project in VS Code:**
* Open VS Code and navigate to the project directory.
* VS Code should automatically detect the `.devcontainer` folder and prompt you to "Reopen in Container".
* Click "Reopen in Container" to start the development environment.
* *Note - In case "Reopen in Container" option does not work then:*
* Look on bottom left of VSCode you will find a remote connection icon (green colored). Click on it.
* It will prompt few option, select "Reopen in Container".

4. Once it Reopen in Container, you need to wait until it finishes the setup process. This process will:
* Build the Docker images for the Open-OSP application and database.
* Configure the images and start the containers.
You will see the extensions in the left sidebar along with the "Workspace" folder.
You will also see the Java extension starts processing the project.

### Initial Compilation

Let's now compile Oscar.

This might take absolutely forever when doing it for the first time.

Once you've built it for the first time, a subsequent full build should take about 2 minutes on MacOS and about 8
minutes on Windows, as we'll have managed to cache a bunch of Maven compilation artifacts.

```zsh
make
```

Once the compilation is successful, a `target/oscar` directory full of artifacts will be created. This is a so-called "
Exploded WAR".

## Access the application:

* Open your web browser and navigate to `http://localhost:8080`.
* You should see the Open-OSP EMR application running.

## Additional Notes

* The `.devcontainer/development/config/shared/local.env` file contains environment variables that can be customized for
your development environment.
* You can find more information about the Open-OSP EMR project and its development environment in the project's
documentation.

## Files Included in the Dev-Container Environment

* **`.devcontainer/devcontainer.json`:** Defines the configuration for the development environment, including Docker
images to use, ports to forward, and user settings.
* **`.devcontainer/development/Dockerfile`:** Defines the Docker image for the Open-OSP application.
* **`.devcontainer/db/Dockerfile`:** Defines the Docker image for the Open-OSP database.
* **`.devcontainer/development/setup/setup.sh`:** Automates the setup process for the development environment.
* **`.devcontainer/docker-compose.yml`:** Defines the Docker Compose configuration for the development environment,
including the services to run and their dependencies.

## Additional Resources

* **Docker Desktop:** https://www.docker.com/products/docker-desktop
* **Dev Containers Extension:** https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
* **VS Code Developing with Dev Containers:** https://code.visualstudio.com/docs/devcontainers/containers
* **Docker Desktop Guide: Getting Started:** https://docs.docker.com/desktop
* **Docker Compose:** https://docs.docker.com/compose**
* **Dockerfile:** https://docs.docker.com/reference/dockerfile/

## Enjoy developing with Open-OSP!
27 changes: 27 additions & 0 deletions .devcontainer/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM mariadb:10.5

# Labels
LABEL author="chitrank dave"
LABEL version=0.0.1
LABEL description="Oscar-db Docker Image for Development Environment"

# Install required packages
RUN apt-get update && apt-get install -y dos2unix \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove

# Adding required files
ADD ./.devcontainer/db/scripts/populate_db.sh /docker-entrypoint-initdb.d/populate_db.sh
ADD ./database /database
ADD ./.devcontainer/development/config/shared/my.cnf /etc/mysql/my.cnf

# Change permissions
RUN chmod 644 /etc/mysql/my.cnf

# Converting script files using dos2unix (Required for Windows)
RUN dos2unix /docker-entrypoint-initdb.d/populate_db.sh
RUN dos2unix /database/mysql/*.sh

# Ports
EXPOSE 3306
11 changes: 11 additions & 0 deletions .devcontainer/db/scripts/populate_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

# Magenta-specific

echo 'Setting up all databases...'
cd /database/mysql || exit 1
echo 'Creating development database...'
./createdatabase_on.sh root password oscar
echo 'Creating test database...'
./createdatabase_on.sh root password oscar_test
cd ../../
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Open-OSP EMR Dev",
"workspaceFolder": "/workspace",
"dockerComposeFile": "docker-compose.yml",
"service": "oscar",
"shutdownAction": "stopCompose",
"customizations": {
"vscode": {
"extensions": [
"waderyan.gitblame",
"[email protected]",
"redhat.fabric8-analytics",
"vscjava.vscode-java-pack"
],
settings: {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
},
"forwardPorts": [
8080,
3306
],
"containerUser": "root",
"remoteUser": "root"
}
93 changes: 93 additions & 0 deletions .devcontainer/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
FROM tomcat:9.0.56-jdk8-openjdk

# Labels
LABEL author="chitrank dave"
LABEL version=0.0.1
LABEL description="Oscar Docker Image for Development Environment"

ARG DRUGREF_DOWNLOAD_URL=https://bitbucket.org/openoscar/drugref/downloads/drugref2.war
ARG OPENOSP_REPO=https://raw.githubusercontent.com/MagentaHealth/open-osp/master/docker/oscar
ARG TOMCAT_PATH=/usr/local/tomcat
ARG DOCS_PATH='/home/oscar/development/volumes'
ARG OSCAR_DOCUMENT="${DOCS_PATH}/OscarDocument"

WORKDIR /workspace

# Install required packages
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends dos2unix curl git wget apt-transport-https \
ca-certificates gnupg lsb-release locales iputils-ping gettext fontconfig libc6 libfreetype6 \
libjpeg62-turbo libpng16-16 libssl1.1 libstdc++6 libx11-6 libxcb1 libxext6 libxtst6 libxrender1 \
xfonts-75dpi xfonts-base zlib1g maven mariadb-client

# Remove useless default apps
RUN rm -rf $TOMCAT_PATH/webapps/ROOT/* \
&& rm -rf $TOMCAT_PATH/webapps/docs \
&& rm -rf $TOMCAT_PATH/webapps/examples \
&& rm -rf $TOMCAT_PATH/webapps/host-manager \
&& rm -rf $TOMCAT_PATH/webapps/manager

# creating tomcat ROOT folder
RUN mkdir -p /usr/local/tomcat/webapps/ROOT

# Taking backup of files
RUN mv $TOMCAT_PATH/conf/logging.properties $TOMCAT_PATH/conf/logging.properties.bak
RUN mv $TOMCAT_PATH/conf/tomcat-users.xml $TOMCAT_PATH/conf/tomcat-users.xml.bak
RUN mv $TOMCAT_PATH/conf/server.xml $TOMCAT_PATH/conf/server.xml.bak

# Download Depenency DrugRef2.war
RUN curl -sSL -o $TOMCAT_PATH/webapps/drugref2.war $DRUGREF_DOWNLOAD_URL


# Adding/Copy required files
ADD ./scripts /scripts
ADD ./setup/setup.sh /setup-dir/setup.sh
ADD ./config/tomcat/conf/server.xml $TOMCAT_PATH/conf/server.xml
COPY ./config/shared/volumes/*.properties /root/

# Download OpenOSP files
RUN curl -s $OPENOSP_REPO/index.jsp > $TOMCAT_PATH/webapps/ROOT/index.jsp
RUN curl -s $OPENOSP_REPO/openosp_favicon.ico > $TOMCAT_PATH/webapps/ROOT/openosp_favicon.ico

RUN curl -s $OPENOSP_REPO/conf/logging.properties > $TOMCAT_PATH/conf/logging.properties
RUN curl -s $OPENOSP_REPO/conf/logging-servlet.properties > $TOMCAT_PATH/conf/logging-servlet.properties
RUN curl -s $OPENOSP_REPO/conf/tomcat-users.xml > $TOMCAT_PATH/conf/tomcat-users.xml


# setting up Document folder
RUN mkdir -p $OSCAR_DOCUMENT/oscar/document \
$OSCAR_DOCUMENT/oscar/billing/download \
$OSCAR_DOCUMENT/oscar/billing/invoices \
$OSCAR_DOCUMENT/oscar/eform/images \
$OSCAR_DOCUMENT/oscar/form/records \
$OSCAR_DOCUMENT/oscar/onEDTDocs/inbox \
$OSCAR_DOCUMENT/oscar/onEDTDocs/outbox \
$OSCAR_DOCUMENT/oscar/onEDTDocs/sent \
$OSCAR_DOCUMENT/oscar/onEDTDocs/archive \
$OSCAR_DOCUMENT/oscar/oscarEncounter/oscarMeasurements/styles \
$OSCAR_DOCUMENT/oscar/incomingdocs

# Converting script files using dos2unix (Required for Windows)
RUN dos2unix /scripts/*
RUN dos2unix /setup-dir/setup.sh

# Change permissions
RUN chmod +x /setup-dir/setup.sh
# setting commands for development
RUN /setup-dir/setup.sh

# Expose Tomcat port
EXPOSE 8080

# Clean up
RUN apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove

# setting up maven repository directory
RUN mkdir -p /root/.m2 && \
chown -R root:root /root/.m2 && \
chmod -R 777 /root/.m2

CMD ["tail", "-f", "/dev/null"]

51 changes: 51 additions & 0 deletions .devcontainer/development/config/shared/local.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

BACKUP_BUCKET="openosp"

OSCAR_TREEISH="spring-hibernate-4"
OSCAR_REPO="https://github.com/ccosp/open-o.git"

# Settings for Flask App that allows the user to run oscar.properties editor online
FLASK_USERNAME=openosp
FLASK_PASSWORD=openosp
FLASK_ENABLED=False

# Settings for the Oscar Login page see /doc/Oscar_login_customization.md for details.

## HTML link to the support provider website.
SUPPORT_LINK="https://openosp.ca"

## Sub text for the support provider. such as telephone or email.
SUPPORT_TEXT="[email protected] <br /> +1 (604) 428-0105 <br /> +1 (800) 511-6778"

## Full name or title of the support provider.
SUPPORT_NAME=

# Expedius environment settings.
# Random password generator $(openssl rand -base64 8)

## Oscar Expedius username
EMR_WS_USERNAME=

## Password for the Expedius Oscar user (set this as an Oscar user)
EMR_WS_PASSWORD=

## Oscar provider number for Expedius user
SERVICE_NUMBER=

MYSQL_ROOT_PASSWORD=password
MYSQL_PASSWORD=password
FAXWS_TOMCAT_PASSWORD=password
CACERTS_PASSWORD=password
STORE_PASS=password
EXPEDIUS_PASSWORD=password

## Name or title of the clinic
CLINIC_NAME="Magenta Health OSCAR Dev"
## clinic subtext such as address phone etc.
CLINIC_TEXT=""
## clinic HTML link to a clinic website if one is supplied.
CLINIC_LINK=""
## Title name in browser tabs (default: OSCAR EMR)
TAB_NAME="OSCAR EMR"

LOCATION=ontario
Loading

0 comments on commit 649f737

Please sign in to comment.