-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add installation scripts and documentation
Adds an installation process for a Docker-ized installation of the application. Resolves #251 Resolves #249
- Loading branch information
Showing
5 changed files
with
196 additions
and
2 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
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,40 @@ | ||
## Ozym Docker Setup | ||
|
||
### Overview | ||
Use this guide to download the latest version of the app and spin up a local instance using Docker Desktop. This process allows a user to: | ||
* Set the passwords for the SQL accounts used by the ozym. | ||
* Apply data migrations to provide sample data to work with. | ||
|
||
This process uses the latest images published under the repository's packages. | ||
|
||
### Prerequisites | ||
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed on your system. | ||
- [winpty](https://github.com/rprichard/winpty/) installed on your system. | ||
- Downloaded the installer zip file from [ozym-docker-installer.zip](https://github.com/hoeyi/Ozym/releases). | ||
|
||
### Steps | ||
|
||
#### 1. Unpack the installation files | ||
Unzip the `ozym-docker-installer.zip` file to the desired directory. | ||
|
||
```sh | ||
unzip ozym-docker-installer.zip -d <PATH_TO_EXTRACT_DIRECTORY> | ||
``` | ||
|
||
#### 2. Start Docker Desktop | ||
Ensure Docker Desktop is running. If it is not, start Docker Desktop from your applications menu. | ||
|
||
#### 3. Run the installation script | ||
This step will pull the required Docker images, spin up a container network, initialize the database with user passwords and roles, then add sample data to play with. You will be prompted for two passwords: | ||
1. For the **[sa]** account. | ||
2. For app database user. | ||
|
||
```sh | ||
cd PATH_TO_EXTRACT_DIRECTORY | ||
./install-ozym-docker-win.sh | ||
``` | ||
|
||
#### 4. Access the application | ||
Find the application by navigating to the mapped port for `ozym-web`. Open your web browser and go to `http://localhost:<port>`, where **<port>** corresponds to the mapped host port in the `docker-compose.yml` file or the port auto-selected by Docker Desktop. You may also wish to explore the API Swagger documentation, which can be found at `http://localhost:<api_port>/swagger`, where **<api_port>** corresponds to the setting in the `docker-compose.yml` file. The API root can be accessed at `http://localhost:<api_port>/api/v1`. | ||
|
||
You can alter the **host:container** port mapping for the installation in the `docker-compose` file, if desired. |
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,45 @@ | ||
name: ozym | ||
services: | ||
ozymweb: | ||
container_name: ozym-web | ||
image: "ghcr.io/hoeyi/ozymweb:latest" | ||
depends_on: | ||
- ozymdb | ||
environment: | ||
OZYM_APP_PASSWORD: ${OZYM_APP_PASSWORD} | ||
ASPNETCORE_ENVIRONMENT: Development | ||
ASPNETCORE_URLS: http://+:80 | ||
ports: | ||
- "80" | ||
|
||
ozymapi: | ||
container_name: ozym-api | ||
image: "ghcr.io/hoeyi/ozymapi:latest" | ||
depends_on: | ||
- ozymdb | ||
environment: | ||
OZYM_APP_PASSWORD: ${OZYM_APP_PASSWORD} | ||
ASPNETCORE_ENVIRONMENT: Development | ||
ASPNETCORE_URLS: http://+:80 | ||
ports: | ||
- "5001:80" | ||
|
||
ozymdb: | ||
container_name: ozym-db | ||
image: mcr.microsoft.com/mssql/server | ||
environment: | ||
ACCEPT_EULA: "Y" | ||
MSSQL_SA_PASSWORD: ${MSSQL_SA_PASSWORD} | ||
OZYM_APP_PASSWORD: ${OZYM_APP_PASSWORD} | ||
# mssql server image isn't available for arm64 architecture, so we use azure-sql instead | ||
# image: mcr.microsoft.com/azure-sql-edge:1.0.4 | ||
# If you really want to use MS SQL Server, uncomment the following line | ||
restart: always | ||
healthcheck: | ||
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -Q 'SELECT 1' || exit 1"] | ||
interval: 10s | ||
retries: 10 | ||
start_period: 10s | ||
timeout: 3s | ||
volumes: | ||
- ./init-ozym-db.sql:/init-ozym-db.sql |
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,33 @@ | ||
-- Create the application server login. | ||
PRINT('Initializing SQL server...') | ||
CREATE LOGIN [OzymAppUser] | ||
WITH PASSWORD=N'$(OZYM_APP_PASSWORD)', | ||
CHECK_EXPIRATION=OFF, | ||
CHECK_POLICY=ON | ||
print('...created login for application user') | ||
GO | ||
-- Create the databases. | ||
CREATE DATABASE [OzymWorks] | ||
CREATE DATABASE [OzymIdentity] | ||
DECLARE @msg nvarchar(72) | ||
SELECT | ||
@msg = STRING_AGG('[' + [name] + ']', ', ') | ||
FROM sys.databases | ||
WHERE [name] LIKE 'Ozym%' | ||
PRINT(FORMATMESSAGE('...created databases: %s.', @msg)) | ||
GO | ||
-- Create database-level users mapped from the server login. Assign both to the | ||
-- db_datareader and db_datawriter roles. | ||
USE [OzymWorks] | ||
CREATE USER [OzymAppUser] FOR LOGIN [OzymAppUser] WITH DEFAULT_SCHEMA=[dbo] | ||
ALTER ROLE db_datareader ADD MEMBER [OzymAppUser] | ||
ALTER ROLE db_datawriter ADD MEMBER [OzymAppUser] | ||
PRINT(FORMATMESSAGE('...created [OzymAppUser] in [%s].', DB_NAME())) | ||
GO | ||
USE [OzymIdentity] | ||
CREATE USER [OzymAppUser] FOR LOGIN [OzymAppUser] WITH DEFAULT_SCHEMA=[dbo] | ||
ALTER ROLE db_datareader ADD MEMBER [OzymAppUser] | ||
ALTER ROLE db_datawriter ADD MEMBER [OzymAppUser] | ||
PRINT(FORMATMESSAGE('...created [OzymAppUser] in [%s].', DB_NAME())) | ||
PRINT('Initialization complete.') | ||
GO |
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,63 @@ | ||
#!/bin/bash | ||
# Installation script for the Docker build of Ozym. | ||
echo -e \ | ||
'Welcome to the Ozym Docker installer!\n | ||
This script starts a Docker network composed of Blazor, REST API, and database | ||
containers. You will be prompted for initial passwords for both the SQL Server [sa] account, | ||
and the web/api database login/user [OzymAppUser]. These passwords will be | ||
set as environment variables in their respective containers.\n' | ||
|
||
# Prompt the user on whether to proceed with installation. | ||
CONTINUE_INSTALL='' | ||
|
||
echo $CONTINUE_INSTALL | ||
|
||
while [ "$CONTINUE_INSTALL" = '' ] | ||
do | ||
read -p 'Continue with installation? (y/N): ' USER_INPUT | ||
echo | ||
if [ "${USER_INPUT^^}" = "Y" ] || [ "${USER_INPUT^^}" = "N" ]; then | ||
CONTINUE_INSTALL="${USER_INPUT^^}" | ||
fi | ||
done | ||
|
||
if [ "$CONTINUE_INSTALL" = "N" ]; then | ||
echo -e '\nInstallation cancelled.' | ||
exit | ||
else | ||
echo -e "\nStarting installation...\n" | ||
read -p 'Enter password for SQL [sa] login: ' -s MSSQL_SA_PASSWORD | ||
echo | ||
read -p 'Enter password for SQL [OzymAppUser] login: ' -s OZYM_APP_PASSWORD | ||
echo | ||
|
||
export MSSQL_SA_PASSWORD="$MSSQL_SA_PASSWORD" | ||
export OZYM_APP_PASSWORD="$OZYM_APP_PASSWORD" | ||
|
||
echo 'Starting Docker network...' | ||
docker compose up -d | ||
|
||
echo 'Starting SQL Server...' | ||
# Wait for the SQL engine to fully initialize to avoid connection error. | ||
sleep 10 | ||
|
||
echo 'Setting up initial database login/user configuration...' | ||
winpty docker exec ozym-db //opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -i init-ozym-db.sql -v OZYM_APP_PASSWORD="$OZYM_APP_PASSWORD" | ||
|
||
echo 'Configurating sample database and applying data migrations...' | ||
winpty docker exec ozym-web //app/ozymworksbundle \ | ||
--connection "Server=ozymdb;Database=OzymWorks;User Id=sa;Password=$MSSQL_SA_PASSWORD;TrustServerCertificate=true" | ||
|
||
echo 'Configurating sample identity database...' | ||
winpty docker exec ozym-web //app/ozymidentitybundle \ | ||
--connection "Server=ozymdb;Database=OzymIdentity;User Id=sa;Password=$MSSQL_SA_PASSWORD;TrustServerCertificate=true" | ||
|
||
echo 'Restarting ozym-web container...' | ||
docker restart ozym-web | ||
|
||
# Clean up variables. | ||
unset MSSQL_SA_PASSWORD | ||
unset OZYM_APP_PASSWORD | ||
|
||
echo -e '\nInitialization complete!' | ||
fi |