Skip to content

Commit

Permalink
CI/CD Pipeline and iSantePlus Version Bump (#14)
Browse files Browse the repository at this point in the history
* Updated CI/CD

* Fix

* Port fix

* Port fix

* Fix

* Cache added

* Cache added

* Cache added

* fix

* fix

* fix

* Db fix

* fixed isanteplus wait

* fixed isanteplus wait

* fixed isanteplus wait

* fixed isanteplus wait

* fixed isanteplus wait

* Fixed isanteplus wait

* Fixed isanteplus wait

* Fix

* Fix

* Update docker-compose.yaml

* Fixes

* Fixes

* Fixes

* Fix

* Bumped iSantePlus Distro Version

* Fix

* DB update

* Updated README.md
  • Loading branch information
pmanko committed Jan 31, 2022
1 parent c521fd6 commit 42b80ba
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 229 deletions.
3 changes: 0 additions & 3 deletions .env

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/build-and-deploy.yml

This file was deleted.

96 changes: 96 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# For every commit or tag that is pushed, but image from it and push this to docker hub

name: CI/CD

on:
pull_request:
branches: [main]
release:
types: [published]
push:
branches: [main]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy:
name: CI/CD
runs-on: ubuntu-latest
env:
USERNAME: ${{ secrets.RELEASE_USERNAME }}
TOKEN: ${{ secrets.RELEASE_TOKEN }}
steps:
-
name: Checkout code
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: ghcr.io/isanteplus/docker-isanteplus-server:ci
load: true
build-args: |
USERNAME=${{ github.actor }}
TOKEN=${{ secrets.GITHUB_TOKEN }}
cache-from: type=inline,ref=user/app:buildcache
cache-to: type=inline,ref=user/app:buildcache,mode=max

- name: Pull containers
run: docker-compose pull qa chrome mysql

- name: Cache containers
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true

- name: Start core containers
run: docker-compose up -d isanteplus mysql chrome

- name: Wait For OpenMRS
run: docker-compose up --exit-code-from wait wait

- name: Show iSantePlus Logs
run: docker-compose logs isanteplus

- name: Run Basic API Tests (https://www.postman.com/itechuw/workspace/haiti-sedish/collection/1525496-192e3c9f-caea-4056-8077-b67af442f01c)
env:
POSTMAN_COLLECTION: https://www.getpostman.com/collections/22647ce67595a103f9c1

run: docker-compose up --exit-code-from newman newman

- name: Run iSantePlus QA Framework (https://github.com/IsantePlus/isanteplus-qaframework)
run: docker-compose up --exit-code-from qa qa
continue-on-error: true

- name: Publish Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
USERNAME=${{ github.actor }}
TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=inline,ref=user/app:buildcache
cache-to: type=inline,ref=user/app:buildcache,mode=max
11 changes: 11 additions & 0 deletions .postman/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "ci",
"values": [
{
"key": "isanteplus-url",
"value": "http://isanteplus:8080",
"enabled": true
}
],
"_postman_variable_scope": "environment"
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM maven:3.6-jdk-8 as download
ARG USERNAME
ARG TOKEN
ARG ISANTEPLUS_VERSION=v2.1.1
ARG ISANTEPLUS_VERSION=v2.2.1

RUN apt-get update; \
apt-get install -y --no-install-recommends \
Expand Down
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,31 @@ This repository is responsible for building the "ghcr.io/isanteplus/isanteplus"

### Build and Publish iSantePlus Image
```sh
docker-compose build --no-cache isanteplus
docker tag <image hash> ghcr.io/isanteplus/isanteplus:<version>
docker tag <image hash> ghcr.io/isanteplus/isanteplus:latest
docker push ghcr.io/isanteplus/isanteplus:latest
docker push ghcr.io/isanteplus/isanteplus:<version>
docker-compose build --no-cache isanteplus -t ghcr.io/isanteplus/docker-isanteplus-server:latest
docker push ghcr.io/isanteplus/docker-isanteplus-server:latest
```

### Use Published Image - Docker Compose
See `docker-compose.yml` file for a working example!

`docker-compose.yml`
Sample `docker-compose` entry:
```json
isanteplus-demo:
container_name: isanteplus-demo
hostname: isanteplus-demo
image: ghcr.io/isanteplus/isanteplus:latest
restart: unless-stopped
env_file:
- ./openmrs/isanteplus_demo/openmrs-server.env
isanteplus:
image: ghcr.io/isanteplus/docker-isanteplus-server:latest
container_name: isanteplus
hostname: isanteplus
ports:
- "8080:8080"
healthcheck:
test: "exit 0"
volumes:
- openmrs-data:/openmrs/data
networks:
- sedish
- /openmrs/data
env_file:
- .env
```

`openmrs-server.env`
```
Sample `.env` file:
```env
OMRS_JAVA_MEMORY_OPTS=-Xmx2048m -Xms1024m -XX:NewSize=128m
OMRS_CONFIG_CONNECTION_SERVER=
OMRS_CONFIG_CREATE_DATABASE_USER=false
Expand Down
61 changes: 0 additions & 61 deletions ci.docker-compose.yaml

This file was deleted.

Empty file added custom_modules/.gitkeep
Empty file.
62 changes: 62 additions & 0 deletions db/mysqld.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This is a pre-configuration for Docker MySQL to allow BinLog and replication necessary configurations for Debezium to work
# see ./openmrs-compose.yaml
# REF: https://github.com/debezium/debezium/blob/master/debezium-connector-mysql/src/test/docker/server-gtids/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql-no-volume
#socket=/var/lib/mysql/mysql.sock
#secure-file-priv=/var/lib/mysql-files
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid

# ----------------------------------------------
# Enable the binlog for replication & CDC
# ----------------------------------------------

# Enable binary replication log and set the prefix, expiration, and log format.
# The prefix is arbitrary, expiration can be short for integration tests but would
# be longer on a production system. Row-level info is required for ingest to work.
# Server ID is required, but this will vary on production systems
server-id = 223344
log_bin = mysql-bin
expire_logs_days = 1
binlog_format = row

0 comments on commit 42b80ba

Please sign in to comment.