Skip to content

Fix building and running under Windows #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
.env.test.local
.env.production.local
.cert
-cert-file
localhost.pem
server/.cert
server/app/bin
web/.cert
node_modules
yarn.lock
71 changes: 71 additions & 0 deletions check-dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Check if the needed tools are installed
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = ‘stop’

$DockerExists=$false
try {if(Get-Command docker) {
$DockerExists=$true
}} Catch {“docker not installed”}

$NpmExists=$false
try {if(Get-Command npm) {
$NpmExists=$true
}} Catch {“npm not installed”}

$YarnExists=$false
try {if(Get-Command yarn) {
$YarnExists=$true
}} Catch {“yarn not installed”}

$ChocoExists=$false
try {if(Get-Command choco) {
$ChocoExists=$true
}} Catch {“choco not installed”}

$MkcertExists=$false
try {if(Get-Command mkcert) {
$MkcertExists=$true
}} Catch {“mkcert not installed”}

$OpensslExists=$false
try {if(Get-Command openssl) {
$OpensslExists=$true
}} Catch {“openssl not installed”}
$ErrorActionPreference=$oldPreference

if($DockerExists -and $NpmExists -and $YarnExists -and $ChocoExists -and $MkcertExists -and $OpensslExists) {
Write-Output "Dependencies docker, npm, yarn, choco, mkcert and openssl are present"
exit 0
}

if(!$DockerExists -or !$NpmExists -or !$ChocoExists) {
if(!$DockerExists) {
Write-Output "Please download and install Docker from https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe";
}

if(!$NpmExists -or !$ChocoExists) {
Write-Output "Please download and install NodeJS package including chocolade from https://nodejs.org/en/download";
}
exit 1;
}

if (!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Installing dependencies requires elevated shell";
exit 1;
}

if(!$YarnExists) {
npm install --global yarn
}

if(!$MkcertExists) {
choco install -y mkcert
}

if(!$OpensslExists) {
choco install -y openssl
}

RefreshEnv
39 changes: 39 additions & 0 deletions create-certificate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$KEY=".cert/localhost.key"
$CERT=".cert/localhost.pem"
$KEYSTORE="server/.cert/keystore.jks"

if ((Test-Path "$KEY") -and (Test-Path "$CERT") -and (Test-Path "$KEYSTORE") -and (Test-Path "web/$CERT")) {
Write-Output "Key and cert exist and will not be recreated";
exit 0;
}

if (!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Generating certificate requires elevated shell";
exit 1;
}

Write-Output "Generating new TLS certificate for localhost"

mkcert -install
if (!(Test-Path ".cert")) {
mkdir -p .cert
}
mkcert -key-file $KEY -cert-file $CERT "localhost"

if (!(Test-Path "web/.cert")) {
mkdir -p web/.cert
}
Copy-Item $KEY web/.cert/localhost.key
Copy-Item $CERT web/.cert/localhost.pem

Write-Output "Converting generated certificate for use in server project"

if (!(Test-Path "server/.cert")) {
mkdir -p server/.cert
}

$openssl = 'C:\Program Files\Git\usr\bin\openssl'
& $openssl pkcs12 -export -in "$CERT" -inkey "$KEY" -out server/.cert/keystore.p12 -name "testCert" -password "pass:example-password"
keytool -importkeystore -noprompt -srckeystore server/.cert/keystore.p12 -srcstoretype pkcs12 -srcstorepass "example-password" -destkeystore server/.cert/keystore.jks -deststorepass "example-password" -destkeypass "example-password"
29 changes: 29 additions & 0 deletions docker-run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if (!(Test-Path "server\.env") -and !(Test-Path "web\.env")) {
Write-Warning "Please populate .env files as described in README.md"
exit 1
}

.\check-dependencies.ps1
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

.\create-certificate.ps1
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Set-Location -Path web
.\build-image.ps1
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Set-Location -Path ..\server
.\build-image.ps1
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Set-Location -Path ..
docker compose up -d
8 changes: 8 additions & 0 deletions run-checks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Set-Location -Path web
yarn lint
yarn test

Set-Location -Path ..\server
.\gradlew check

Set-Location -Path ..
6 changes: 6 additions & 0 deletions server/build-image.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
./gradlew clean shadowJar

docker build -t example-integration-server:test `
--build-arg jar=app/build/libs/server-all.jar `
--build-arg keystore=.cert/keystore.jks `
.
3 changes: 3 additions & 0 deletions web/build-image.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yarn && yarn build

docker build --no-cache -t example-integration-web:test .