Docker Local Deployment
No edit summary
No edit summary
Line 17: Line 17:
'''i)''' Start with a base image of a linux distribution
'''i)''' Start with a base image of a linux distribution


'''ii)''' Install the .NET SDK. For this case we will use a Microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour [https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md from here].<syntaxhighlight>
'''ii)''' Install the .NET SDK. For this case we will use a Microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour from  https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md.<syntaxhighlight>
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
</syntaxhighlight>'''iii)''' Copy the MDriven Server  files to the image or download the latest MDriven Server and  extract it into the image.<syntaxhighlight>
</syntaxhighlight>'''iii)''' Copy the MDriven Server  files to the image or download the latest MDriven Server and  extract it into the image.<syntaxhighlight>
Line 35: Line 35:
     && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \
     && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \
     && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"
     && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"
</syntaxhighlight>'''iv)''' Set the package source for VistaDB<syntaxhighlight>
</syntaxhighlight>Install Curl, unzip and xmstarlet packages for downloading and extracting the latest version of the MDriven Server for Linux. It is important to clean up residue files from upgrading linux packages and file downloads. This is to keep the image size from getting overly big.
 
'''iv)''' Set the package source for VistaDB<syntaxhighlight>
RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB
RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB
</syntaxhighlight>'''v)''' Lastly start the MDriven Server<syntaxhighlight>
</syntaxhighlight>'''v)''' Lastly start the MDriven Server<syntaxhighlight>
Line 44: Line 46:
'''i)''' Start with a base image of a linux distribution
'''i)''' Start with a base image of a linux distribution


'''ii)''' Install the .NET SDK. For this case we will use a microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour [https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md from here].
'''ii)''' Install the .NET SDK. For this case we will use a microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour from https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md .<syntaxhighlight>
 
'''iii)''' Copy the MDriven Turnkey files to the image or download the latest MDriven Turnkey and  extract it into the container.
 
'''iv)''' Copy the Turnkey Settings into the App_Data folder.
 
'''v)''' Lastly start the MDriven Turnkey.
 
 
 
 
Create a docker file for the MDriven Server
 
 
 
Contents of ''<u>MDrivenServer.Dockerfile</u>''<syntaxhighlight lang="dockerfile">
# syntax=docker/dockerfile:1
 
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
 
RUN apk add --upgrade --no-cache \
        curl \
        unzip \
        xmlstarlet
 
WORKDIR /app
 
ARG MS_VERSION
 
RUN curl -O https://mdriven.net/PublicDownloads/MDrivenServerOnCoreVersion.xml \
    && MS_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenServerOnCoreVersion.xml) \
    && rm -f MDrivenServerOnCoreVersion.xml \
    && curl -O "https://mdriven.net/PublicDownloads/MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"
 
 
RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB
 
ENTRYPOINT ["dotnet", "AppCompleteGenericCore.dll", "-port=5010", "-nohttps"]
</syntaxhighlight>
{| class="wikitable"
!Command
!Description
|-
|<code>FROM mcr.microsoft.com/dotnet/sdk:</code><code>8.0-alpine</code>
|Base image for the container MDriven Server app. An Alpine Linux distribution with .NET 8.0 SDK for running .NET applications.
Check https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md for more .NET SDK container images.
|-
|<code>RUN apk add --upgrade --no-cache \</code><code>        curl \</code>
 
<code>        unzip \</code>
 
<code>        xmlstarlet</code>
|Updates the existing linux packages and installs packages:  curl for downloading files, unzip for extracting zip file contents and xmlstarlet for parsing xml content.
|-
|<code>WORKDIR /app</code>
|Sets the working dir for the following commands.
|-
|<code>ARG MS_VERSION</code>
|Creates MS_VERSION build-time variable called MS_VERSION.
|-
|<code>RUN curl -O <nowiki>https://mdriven.net/PublicDownloads/MDrivenServerOnCoreVersion.xml</nowiki> \</code><code>    && MS_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenServerOnCoreVersion.xml) \</code>
 
<code>    && rm -f MDrivenServerOnCoreVersion.xml \</code>
 
<code>    && curl -O "<nowiki>https://mdriven.net/PublicDownloads/MDrivenServerCoreLinux_${MS_VERSION}.zip</nowiki>" \</code>
 
<code>    && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \</code>
 
<code>    && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"</code>
|Get the current MDriven Version, use it to download the current MDriven Server app and unzip it into the current working directory. If you have an existing MDriven Server instance, copy the files to the container.<syntaxhighlight>
COPY ./mdriven-files .
</syntaxhighlight>
|-
|<code>RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB</code>
|Add the VistaDB package source.
|-
|<code>ENTRYPOINT ["dotnet", "AppCompleteGenericCore.dll", "-port=5010", "-nohttps"]</code>
|Run the application on port 5010 and over http.
|}Create a docker file for the Turnkey Server
 
contents of ''<u>MDrivenTurnkey.Dockerfile</u>''<syntaxhighlight lang="dockerfile">
# syntax=docker/dockerfile:1
 
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
 
</syntaxhighlight>'''iii)''' Copy the MDriven Turnkey files to the image or download the latest MDriven Turnkey and  extract it into the container.<syntaxhighlight>
RUN apk add --upgrade --no-cache \
RUN apk add --upgrade --no-cache \
         curl \
         curl \
Line 153: Line 71:
     && unzip "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
     && unzip "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
     && rm -f "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip"
     && rm -f "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip"
</syntaxhighlight>Install Curl, unzip and xmstarlet packages for downloading and extracting the latest version of the MDriven Server for Linux. install locale settings if they are not available in the linux image and set language. It is important to clean up residue files from upgrading linux packages and file downloads. This is to keep the image size from getting overly big.


 
'''iv)''' Copy the Turnkey Settings into the App_Data folder.<syntaxhighlight>
COPY ./turnkey-settings ./App_Data
COPY ./turnkey-settings ./App_Data
 
</syntaxhighlight>Contents of ''turnkey-settings/HardServerUrl.xml''<syntaxhighlight lang="xml">
 
ENTRYPOINT ["dotnet", "StreaminAppCoreWebApp.dll", "-port=5020", "-nohttps"]
</syntaxhighlight>
'''NOTE:''' For Turnkey Server, install locale packages and set language to prevent locale errors. The Turnkey uses the OS locale settings to determine which locale file is used by the Turnkey.
copy Turnkey settings to Turnkey ''APP_Data'' Folder. The turnkey-settings folder contains:
 
HardServerUrl Settings: To specify the address to be used by the Turnkey Server.
 
MDrivenServerOverride Settings: TO specify credentials for connecting to the  MDriven Server
 
contents of <u>turnkey-settings/HardServerUrl.xml</u><syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root HardServerUrl="http://localhost:5020">
<root HardServerUrl="http://localhost:5020">
</root>
</root>
</syntaxhighlight>contents of <u>turnkey-settings/MDrivenServerOverride.xml</u><syntaxhighlight lang="xml">
</syntaxhighlight>Contents of ''turnkey-settings/MDrivenServerOverride.xml''<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<root>
   <MDrivenServerOverride MDrivenServerPWD="123456" MDrivenServerUSER="a">http://mdriven-server:5010</MDrivenServerOverride>
   <MDrivenServerOverride MDrivenServerPWD="123456" MDrivenServerUSER="a">http://mdriven_server:5010</MDrivenServerOverride>
</root>
</root>
</syntaxhighlight>contents of ''<u>compose.yaml</u>''<syntaxhighlight lang="yaml">
</syntaxhighlight>'''v)''' Lastly start the MDriven Turnkey.<syntaxhighlight>
ENTRYPOINT ["dotnet", "StreaminAppCoreWebApp.dll", "-port=5020", "-nohttps"]
</syntaxhighlight>
 
=== Compose File ===
The compose file is a single configuration file for building and starting the container images for the MDriven Server and MDriven Turnkey.<syntaxhighlight lang="yaml">


services:
services:

Revision as of 16:48, 14 November 2024

This page was created by Charles on 2024-11-11. Last edited by Charles@mdriven.net on 2025-03-11.

Deploying the MDriven Server and Turnkey on your local machine.

1. Start by installing Docker Desktop

-------------- Folder Structure --------------

\---Apps
    |   compose.yaml                    - [configuration file for starting the MDriven Turnkey and Server as services]
    |   MDrivenServer.Dockerfile        - [Docker file for creating MDriven Server container image]
    |   MDrivenTurnkey.Dockerfile       - [Docker file for creating MDriven Turnkey containere image]
    \---turnkey-settings
        |   HardServerUrl.xml           - [Setting for specifying the URL to be used by the Turnkey Server]
        |   MDrivenServerOverride.xml   - [Settings for the Turnkey to connect to the MDriven Server]

MDrivenServer Dockerfile

i) Start with a base image of a linux distribution

ii) Install the .NET SDK. For this case we will use a Microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour from https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md.

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

iii) Copy the MDriven Server files to the image or download the latest MDriven Server and extract it into the image.

RUN apk add --upgrade --no-cache \
        curl \
        unzip \
        xmlstarlet 

WORKDIR /app

ARG MS_VERSION

RUN curl -O https://mdriven.net/PublicDownloads/MDrivenServerOnCoreVersion.xml \
    && MS_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenServerOnCoreVersion.xml) \
    && rm -f MDrivenServerOnCoreVersion.xml \
    && curl -O "https://mdriven.net/PublicDownloads/MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"

Install Curl, unzip and xmstarlet packages for downloading and extracting the latest version of the MDriven Server for Linux. It is important to clean up residue files from upgrading linux packages and file downloads. This is to keep the image size from getting overly big. iv) Set the package source for VistaDB

RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB

v) Lastly start the MDriven Server

ENTRYPOINT ["dotnet", "AppCompleteGenericCore.dll", "-port=5010", "-nohttps"]

MDriven Turnkey Dockerfile

i) Start with a base image of a linux distribution

ii) Install the .NET SDK. For this case we will use a microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and linux flavour from https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md .

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

iii) Copy the MDriven Turnkey files to the image or download the latest MDriven Turnkey and extract it into the container.

RUN apk add --upgrade --no-cache \
        curl \
        unzip \
        xmlstarlet \
        musl-locales

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

RUN locale -a

WORKDIR /app

ARG TK_VERSION

RUN curl -O https://mdriven.net/PublicDownloads/MDrivenTurnkeyOnCoreVersion.xml \
    && TK_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenTurnkeyOnCoreVersion.xml) \
    && rm -f MDrivenTurnkeyOnCoreVersion.xml \
    && curl -O "https://mdriven.net/PublicDownloads/MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
    && unzip "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
    && rm -f "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip"

Install Curl, unzip and xmstarlet packages for downloading and extracting the latest version of the MDriven Server for Linux. install locale settings if they are not available in the linux image and set language. It is important to clean up residue files from upgrading linux packages and file downloads. This is to keep the image size from getting overly big. iv) Copy the Turnkey Settings into the App_Data folder.

COPY ./turnkey-settings ./App_Data

Contents of turnkey-settings/HardServerUrl.xml

<?xml version="1.0" encoding="utf-8"?>
<root HardServerUrl="http://localhost:5020">
</root>

Contents of turnkey-settings/MDrivenServerOverride.xml

<?xml version="1.0" encoding="utf-8"?>
<root>
  <MDrivenServerOverride MDrivenServerPWD="123456" MDrivenServerUSER="a">http://mdriven_server:5010</MDrivenServerOverride>
</root>

v) Lastly start the MDriven Turnkey.

ENTRYPOINT ["dotnet", "StreaminAppCoreWebApp.dll", "-port=5020", "-nohttps"]

Compose File

The compose file is a single configuration file for building and starting the container images for the MDriven Server and MDriven Turnkey.

services:
  mdriven-server:
    build:
      dockerfile: MDrivenServer.Dockerfile
    networks:
      - app-net
    volumes:
      - mdriven-server-data:/app
    ports:
      - 5010:5010
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5010"]
      interval: 24h
      timeout: 30s
      retries: 5
      start_period: 30s


  mdriven-turnkey:
    build:
      dockerfile: MDrivenTurnkey.Dockerfile
    networks:
      - app-net
    volumes:
      - mdriven-turnkey-data:/app
    ports:
      - 5020:5020
    depends_on:
      - mdriven-server


volumes:
  mdriven-turnkey-data:
  mdriven-server-data:
networks:
  app-net:

mdriven-server: creates a service for the MDriven Server using the MDrivenServer.Dockerfile file, the MDriven Server is connected to and available in the app-net network. The service is binding port 5010 on your host machine to 5010 port on which the MDriven Server is running in the container. The volume is added to persist the MDriven Server files in the /app folder whereit is currently located and running in the container. This allows for updating of the linux OS packages and images while leaving your Server data intact. without a volume, the server data is destroyed when container stops running.

The health check: on the MDriven Server is to solve the issue of Vista DB locking itself, a check is performed every after 24 hours and server is restarted to clear the lock state.

mdriven-turnkey: creates a service for the MDriven Turnkey using the MDrivenTurnkey.Dockerfile file, the MDriven Turnkey is connected to and available in the app-net network. The service is binding port 5020 on your host machine to 5020 port on which the MDriven Turnkey is running in the container. The volume is added to persist the MDriven Turnkey files in the /app folder where it is currently located and running in the container.

Adding depends_on: ensures the Turnkey service only starts after the MDriven Server has started.

app-net: is a network shared by the two services so that they can be able to communicate to each other.

See also: