Initial open source release

This commit is contained in:
Ronni Skansing
2025-08-21 16:14:09 +02:00
commit 11cf01f08e
488 changed files with 97180 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
echo "### Building frontend"
# remove any old builds
rm -rf phishingclub/frontend/frontend/build
mkdir -p phishingclub/frontend/frontend/build
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
node:alpine \
sh -c "npm ci && npm run build-production"
# Get current user and group IDs
USER_ID=$(id -u)
GROUP_ID=$(id -g)
sudo chown -R $USER_ID:$GROUP_ID phishingclub/frontend/build
sudo mv phishingclub/frontend/build ./phishingclub/frontend/frontend/
echo "### Building backend"
HASH=$(git rev-parse --short HEAD)
echo "Building with hash: $HASH"
echo "building..."
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
golang:alpine \
go build -trimpath \
-ldflags="-X github.com/phishingclub/phishingclub/version.hash=ph$HASH" \
-tags production -o ../build/phishingclub main.go
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
HASH=$(git rev-parse --short HEAD)
echo "Building backend with hash: $HASH"
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
golang \
go build -trimpath \
-ldflags="-X github.com/phishingclub/phishingclub/version.hash=ph$HASH" \
-tags production -o ../build/phishingclub main.go
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
echo "### Building frontend"
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
node:alpine \
sh -c "npm ci && npm run build-production"
+66
View File
@@ -0,0 +1,66 @@
#!/bin/bash
set -e
# Get the current version from the VERSION file
VERSION=$(cat phishingclub/frontend/version/VERSION | tr -d '\n\r ')
# Check if version is valid
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format. Expected semver format (e.g., 0.9.0)"
exit 1
fi
# Get current git hash
GIT_HASH=$(git rev-parse --short HEAD)
# Create build directory
mkdir -p build
# Prompt for confirmation
echo "Ready to build and tag release v$VERSION ($GIT_HASH)"
read -p "Continue? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Operation cancelled"
exit 1
fi
# Build frontend
echo "Building frontend..."
# remove any old builds
rm -rf phishingclub/frontend/frontend/build
mkdir -p phishingclub/frontend/frontend/build
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
node:alpine \
sh -c "npm ci && npm run build-production"
# Get current user and group IDs
USER_ID=$(id -u)
GROUP_ID=$(id -g)
sudo chown -R $USER_ID:$GROUP_ID phishingclub/frontend/build
mv phishingclub/frontend/build ./phishingclub/frontend/frontend/
# Build the application
echo "Building application..."
sudo docker run --rm \
-v "$(pwd)":/app \
-w /app/phishingclub/frontend \
golang:alpine \
go build -trimpath \
-ldflags="-X github.com/phishingclub/phishingclub/version.hash=ph$GIT_HASH" \
-tags production -o ../build/phishingclub_${VERSION} main.go
echo "Build completed successfully: build/phishingclub_${VERSION}"
echo "Build completed successfully!"
echo "Created files:"
ls -lh build/
cd ..
echo "Release tagged as v$VERSION"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Exit on any error
set -e
echo "Generating licenses..."
# Create temp directory if it doesn't exist
mkdir -p /tmp/licenses
# Generate backend licenses
echo "Generating backend licenses..."
sudo docker compose exec -T backend bash -c "go install github.com/google/go-licenses@latest && \
go-licenses report --ignore github.com/phishingclub/phishingclub --template ./utils/ossTemplate.tpl ./... > /tmp/backend-licenses.md 2> /dev/null"
sudo docker compose cp backend:/tmp/backend-licenses.md /tmp/licenses/
# Generate frontend licenses
echo "Generating frontend licenses..."
sudo docker compose exec -T frontend bash -c "npm run --silent license-report > /tmp/frontend-licenses.json 2>/dev/null"
sudo docker compose cp frontend:/tmp/frontend-licenses.json /tmp/licenses/
# Combine licenses
echo "Combining licenses..."
cat /tmp/licenses/backend-licenses.md > phishingclub/frontend/static/licenses.txt
echo -e "\n\n" >> phishingclub/frontend/static/licenses.txt
cat /tmp/licenses/frontend-licenses.json >> phishingclub/frontend/static/licenses.txt
# Cleanup
rm -rf /tmp/licenses
echo "License file generated at phishingclub/frontend/static/licenses.txt"
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
# generate private key
openssl genrsa -out test.key 2048
# generate self-signed certificate
# generate certificate
openssl req -new -x509 -key test.key -out test.pem -days 365