-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: publish | ||
on: | ||
tags: | ||
jobs: | ||
publish-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build the docker Docker image | ||
run: | | ||
docker build . --tag ghcr.io/openimis/openimis-be:${GITHUB_REF##*/} | ||
docker run ghcr.io/openimis/openimis-be:${GITHUB_REF##*/} | ||
docker push ghcr.io/openimis/openimis-be:${GITHUB_REF##*/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM mcr.microsoft.com/mssql/server:2017-latest | ||
ARG ACCEPT_EULA=Y | ||
ENV ACCEPT_EULA=N | ||
ARG SA_PASSWORD=IMISuserP@s | ||
ENV SA_PASSWORD=IMISuserP@s | ||
ENV DB_USER_PASSWORD=IMISuserP@s | ||
ENV DB_NAME=IMIS | ||
ENV DB_USER=IMISUser | ||
RUN mkdir -p /app | ||
COPY script/* /app/ | ||
WORKDIR /app | ||
|
||
ENV SQL_SCRIPT_URL="https://github.com/openimis/database_ms_sqlserver/releases/latest/download/sql-files.zip" | ||
ENV INIT_MODE='empty' | ||
RUN apt-get update && apt-get install unzip -y && rm -rf /var/lib/apt/lists/* | ||
RUN chmod a+x /app/*.sh | ||
CMD /bin/bash ./entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# https://www.softwaredeveloper.blog/initialize-mssql-in-docker-container | ||
|
||
# Run Microsoft SQl Server and initialization script (at the same time) | ||
/app/run-initialization.sh & /opt/mssql/bin/sqlservr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
data=$(/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "SELECT COUNT(*) FROM master.dbo.sysdatabases WHERE name = N'$DB_NAME'" | tr -dc '0-9'| cut -c1 ) | ||
if [ ${data} -eq "1" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Wait to be sure that SQL Server came up | ||
sleep 60s | ||
|
||
|
||
# DATABSE initialisation | ||
|
||
echo "Database initialisaton" | ||
# if the table does not exsit it will create the table | ||
|
||
# get "1" if the database exist : tr get only the integer, cut only the first integer (the second is the number of row affected) | ||
data=$(/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "SELECT COUNT(*) FROM master.dbo.sysdatabases WHERE name = N'$DB_NAME'" | tr -dc '0-9'| cut -c1 ) | ||
if [ ${data} -eq "0" ]; then | ||
echo 'download full demo database' | ||
wget $SQL_SCRIPT_URL -O /sql-files.zip | ||
unzip /sql-files.zip -d /app | ||
echo 'create database user' | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "CREATE LOGIN $DB_USER WITH PASSWORD='${SA_PASSWORD}', CHECK_POLICY = OFF" | ||
|
||
echo 'create database' | ||
#/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP DATABASE IF EXISTS $DB_NAME" | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "CREATE DATABASE $DB_NAME" | ||
if [ ${INIT_MODE} -eq "demo" ]; then | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i /app/fullDemoDatabase.sql -d $DB_NAME | grep . | uniq -c | ||
else | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i /app/fullEmptyDatabase.sql -d $DB_NAME | grep . | uniq -c | ||
fi | ||
echo ' give to the user the access to the database' | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "EXEC sp_changedbowner '$DB_USER'" -d $DB_NAME | ||
else | ||
echo "database already existing, nothing to do" | ||
fi | ||
|
||
# manual cleaning command | ||
# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP DATABASE $DB_NAME" | ||
# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP LOGIN $DB_USER" |