Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CodeMeterLicenseServer/.theia/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"galileo.logo": "",
"galileo.title": "CodeMeter",
"galileo.description": "PERFECTION IN PROTECTION, LICENSING AND SECURITY",
"galileo.widget_label": "Wibu Portal",
"galileo.social_links": [
{
],
"galileo.ui_components": [
{
"type": "custom",
"title": "Getting Started",
"content": [
{
"title": "🏡 Code Meter Endpoint",
"href": "/codemeter/",
"priority": 0
}
]
},
],
"workbench.colorTheme": "Galileo Dark"
}
26 changes: 26 additions & 0 deletions CodeMeterLicenseServer/.theia/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"tasks": [
{
"id": "start-code-meter",
"label": "Start Code Meter",
"description": "Start the Code Meter process.",
"type": "shell",
"command": "tmux new -s codemeter /usr/sbin/CodeMeterLin -v -l -n+ || tmux a -t codemeter",
"icon": {
"prefix": "far",
"name": "play-circle"
}
},
{
"id": "start-web-admin",
"label": "Start Web Admin Portal",
"description": "Start web admin user portal.",
"type": "shell",
"command": "tmux new -s webadmin /usr/sbin/CmWebAdmin || tmux a -t webadmin",
"icon": {
"prefix": "fas",
"name": "download"
}
}
]
}
11 changes: 11 additions & 0 deletions CodeMeterLicenseServer/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"json.schemas": [
{
"fileMatch": [
"/.theia/settings.json"
],
"url": "./widget-config.schema.json"
}
]

}
16 changes: 16 additions & 0 deletions CodeMeterLicenseServer/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:8888 {
log
redir / /ui/
redir /auth/portal /ui/

import /etc/gatekeeper/auth.txt

handle_path /codemeter/* {
reverse_proxy http://localhost:22350
}

handle_path /webadmin/* {
reverse_proxy http://localhost:22352
}

}
76 changes: 76 additions & 0 deletions CodeMeterLicenseServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# get the go runtime
FROM golang as go-build

# get the Galileo IDE
FROM hypernetlabs/galileo-ide:linux AS galileo-ide

#FROM debian:stable-slim
FROM wiburp/cm-srv

RUN apt-get update && apt upgrade -y && \
apt-get install -y --no-install-recommends curl ca-certificates vim curl tmux git wget zip unzip vim speedometer net-tools \
&& apt install -y software-properties-common gpg \
&& apt update -y \
&& apt install -y \
supervisor kmod fuse\
libsecret-1-dev \
&& curl -fsSL https://deb.nodesource.com/setup_12.x | bash - \
&& apt install -y nodejs \
&& curl https://rclone.org/install.sh

# get the go runtime and opera executable
COPY --from=go-build /go /go
COPY --from=go-build /usr/local/go /usr/local/go
ENV PATH $PATH:/usr/local/go/bin:/home/galileo:/home/galileo/.local/bin
ENV GOPATH=/usr/local/go

RUN go get -u github.com/bitnami/bcrypt-cli

RUN useradd -ms /bin/bash galileo

COPY --chown=galileo .theia /home/galileo/.theia
COPY --chown=galileo .vscode /home/galileo/.vscode

# Find direct link at https://www.wibu.com/support/user/user-software.html
# Link for Version 7.40 2021-12-17 multilanguage Linux 64-bit DEB Package
ARG CODEMETER_PKG_URL=https://www.wibu.com/support/user/user-software/file/download/8870.html?tx_wibudownloads_downloadlist%5BdirectDownload%5D=1&tx_wibudownloads_downloadlist%5BuseAwsS3%5D=0&cHash=7188a558a65794c26a09b707872ee677
RUN curl "${CODEMETER_PKG_URL}" > codemeter.deb
RUN apt-get install -y ./codemeter.deb

# get the Caddy server executables and stuff
COPY --from=galileo-ide --chown=galileo /caddy/caddy /usr/bin/caddy
COPY --from=galileo-ide --chown=galileo /caddy/header.html /etc/assets/header.html
COPY --from=galileo-ide --chown=galileo /caddy/users.json /etc/gatekeeper/users.json
COPY --from=galileo-ide --chown=galileo /caddy/auth.txt /etc/gatekeeper/auth.txt
COPY --from=galileo-ide --chown=galileo /caddy/settings.template /etc/gatekeeper/assets/settings.template
COPY --from=galileo-ide --chown=galileo /caddy/login.template /etc/gatekeeper/assets/login.template
COPY --from=galileo-ide --chown=galileo /caddy/custom.css /etc/assets/custom.css
COPY --chown=galileo rclone.conf /home/galileo/.config/rclone/rclone.conf
COPY --chown=galileo Caddyfile /etc/

# get the galileo IDE
COPY --from=galileo-ide --chown=galileo /.galileo-ide /home/galileo/.galileo-ide

COPY Server.ini /etc/wibu/CodeMeter/Server.ini

RUN chmod -R a=rwx /etc/wibu/CodeMeter/

WORKDIR /home/galileo/.galileo-ide

# get supervisor configuration file
COPY supervisord.conf /etc/

# set environment variable to look for plugins in the correct directory
ENV SHELL=/bin/bash \
THEIA_DEFAULT_PLUGINS=local-dir:/home/galileo/.galileo-ide/plugins
ENV USE_LOCAL_GIT true
ENV GALILEO_RESULTS_DIR /home/galileo

# set login credentials and write them to text file
ENV USERNAME "a"
ENV PASSWORD "b"
RUN sed -i 's,"username": "","username": "'"$USERNAME"'",1' /etc/gatekeeper/users.json && \
sed -i 's,"hash": "","hash": "'"$(echo -n "$(echo $PASSWORD)" | bcrypt-cli -c 10 )"'",1' /etc/gatekeeper/users.json

ENTRYPOINT ["sh", "-c", "supervisord"]

14 changes: 14 additions & 0 deletions CodeMeterLicenseServer/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

Copyright 2020 Hypernet Labs, Inc.

Licensed under the Hypernet Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:

https://github.com/GoHypernet/CommunityLicense/blob/main/Hypernet%20Community%20License.pdf

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.
79 changes: 79 additions & 0 deletions CodeMeterLicenseServer/Server.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[Backup]
Interval=24
Path=/var/lib/CodeMeter/Backup
UpdateCertifiedTime=0

[General]
ActionTimeIntervall=10
ApiCommunicationMode=1
BindAddress=0.0.0.0
CleanUpTimeOut=120
CmInstanceUid=2922213357
CmWANPort=22351
EnabledContainerTypes=4294967295
ExePath=/usr/sbin
HelpFile=/usr/share/doc/CodeMeter
IsCmWANServer=1
IsNetworkServer=1
LogCleanupTimeout=336
LogCmActDiag=1
LogLicenseTracking=0
LogLicenseTrackingPath=/var/log/CodeMeter
Logging=0
LogPath=/var/log/CodeMeter
MaxMessageLen=67108864
NetworkAccessFsb=0
NetworkPort=22350
NetworkTimeout=40
ProxyPort=0
ProxyServer=
ProxyUser=
UseSystemProxy=1
StartDaemon=1
TimeServerTimeout=20
TimeServerURL1=cmtime.codemeter.com
TimeServerURL2=cmtime.codemeter.us
TimeServerURL3=cmtime.codemeter.de
UDPCachingTime=20
UDPWaitingTime=1000
DiagnoseLevel=0
ApiCommunicationModeServer=1
ListRejectedAllocations=0
ListRejectedAllocationsFirmcode=0
ListRejectedAllocationsMaxEntries=1000
HostNameResolveTimeout=10
ProxyPasswordSecure=#/54ZSLk+bHAoCAZnOzmDgBbMPLoQcgaBRDPJ/0gM3Uo=
WebSocketKeepAliveTimeout=300
LtClientsCleanupTime=2400
DisableWebSocketVersions=0

[BorrowClient]

[BorrowServer]

[BorrowManage]

[CmAct\ErrorLogger]

[CmAct\PSNs]

[HTTP]
DigestAuthentication=0
RemoteRead=0
Port=22352
ReadAuthenticationEnabled=0
ReadPassword=
WritePassword=
PreparedBorrowingConfiguration=0

[TripleModeRedundancy]
TmrEnabled=0

[HTTPS]
Port=22353
Enabled=2
CertificateChainFile=
PrivateKeyFile=

[ServerSearchList]

3 changes: 3 additions & 0 deletions CodeMeterLicenseServer/rclone.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Fantom Fast Sync]
type = tardigrade
access_grant =
31 changes: 31 additions & 0 deletions CodeMeterLicenseServer/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid
logfile=/dev/fd/1
logfile_maxbytes=0

[program:galileo-ide]
priority=1
command=node /home/galileo/.galileo-ide/src-gen/backend/main.js --hostname=0.0.0.0
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:caddy]
priority=2
command=/usr/bin/caddy run -adapter caddyfile -config /etc/Caddyfile
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[unix_http_server]
file=/tmp/supervisor.sock
chmod=0700

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ RUN echo node .\src-gen\backend\main.js C:\Users\Public\tuflow --hostname=0.0.0.
ENV SCOOP "C:\scoop"
ENV SCOOP_HOME "C:\scoop\apps\scoop\current"

# install CodeMeter runtime
ENV CODEMETER_URL="https://www.wibu.com/support/user/user-software/file/download/8858.html?tx_wibudownloads_downloadlist%5BdirectDownload%5D=1&tx_wibudownloads_downloadlist%5BuseAwsS3%5D=0&cHash=1357cb7ae0883c984f3d6b130dc16a96"
COPY codemeter_install.ps1 codemeter_install.ps1
RUN powershell.exe .\codemeter_install.ps1

# retrieve CodeMeter configuration script
COPY codemeter_configure.ps1 codemeter_configure.ps1

# set environment variable to look for the pulins in the correct directory
ENV THEIA_DEFAULT_PLUGINS "local-dir:c:\Users\Public\galileo-ide\plugins"

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ variables `EXE_iDP` and `EXE_iSP` should be set to the desired version and used
these environment variables include the `-nmb` and `-nc` flags to ensure that GUI popup boxes do not stall the headless
session.

In order to run realistic Tuflow models, a Tuflow license is required. This containerized framework embeds Wibu System's
CodeMeter service that the Tuflow executable uses to attest for appropriate licensing. The URL/IP address of the licensing
server is specified by the CODEMETERADDRESS environment variable.

This framework comes with a React-based IDE for interactive sessions. A password and username must be set via the
`PASSWORD` and `USERNAME` environment variables for authentication with the interactive session. The IDE is served on
port 3000 and the authenticated enpoint which reverse-proxies the app is on port 8888.
Expand All @@ -44,11 +48,11 @@ This will build a Docker image called `tuflow` that contains the tuflow.exe runt
## Running

The working directory of any Tuflow container created from the base image defined by this project's Dockerfile is set to
be `C:\Users\Public\tuflow`. The Tuflow executable and all requisite runtime libraries are included in the
`C:\exe\2018-03-AC\` folder.
be `C:\Users\Public\tuflow`. The Tuflow executables and all requisite runtime libraries are included in the
`C:\exe\*` subfolders.

Two environment variables are set for convenience: `EXE_iSP` and `EXE_iDP`. These environment variables contain the installation
path of the single and double precision executables respectively.

A runtime .bat file called `run_tuflow.bat` is used as the entrypoint for the container. This .bat file executes whatever .bat file
the user places in the wording directory and sets via the environment variable `TUFLOW_BAT`.
the user places in the working directory and sets via the environment variable `TUFLOW_BAT`.
9 changes: 9 additions & 0 deletions codemeter_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Write-Host "Downloading CodeMeter runtime installer..."
# Find direct link at https://www.wibu.com/support/user/user-software.html
# Link for Windows version 7.40 2021-12-17 multilanguage 64-bit
Invoke-WebRequest -Uri $Env:CODEMETER_URL -OutFile ./codemeter.exe

Write-Host "Installing CodeMeter runtime..."
Start-Process ./codemeter.exe -ArgumentList "/ComponentArgs ""*"":""/qn""" -Wait -Verbose

Write-Host "Done installing CodeMeter runtime"
Binary file added exe/TUFLOW.2020-10-AB.zip
Binary file not shown.
Binary file added exe/TUFLOW.2020-10-AC.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions run_tuflow.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
powershell -command "Expand-Archive -DestinationPath . -Force '%MODELARCHIVE%'"
powershell -command "Remove-Item -Path '%MODELARCHIVE%%'"
powershell -command "Write-Host 'Configuring CodeMeter...'"
"\Program Files (x86)\CodeMeter\Runtime\bin\cmu32.exe" --add-server %CODEMETERADDRESS%
powershell -command "Restart-Service CodeMeter.exe"
cd %RUNS_DIR%
".\%TUFLOW_BAT%"