Skip to content

Commit

Permalink
Initial commit of portal
Browse files Browse the repository at this point in the history
intial commit
  • Loading branch information
MaxWaldorf authored Aug 30, 2024
2 parents d9c20a7 + 23cd683 commit 9cc1816
Show file tree
Hide file tree
Showing 19 changed files with 3,675 additions and 2 deletions.
76 changes: 76 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#Ignore npm files
**/.env
**/.parcel-cache/*
**.lock
**/dist/*
**/node_modules/*
**/package-lock.json

#Ignore the git and cache folders
.git
.gitignore

# Docker build spec
Dockerfile

# Git repository metadata
.git
**/.gitignore
.cache
.drone.yml
.github

# Object code
**/*.o
**/*.so
**/*.lo
**/*.la

# gcov files
**/*.gcda
**/*.gcov
**/*.gcno

# Backup files
**/*~

# Release files
**/*.tar.gz

# Files currently being edited by vim or vi
**/*.swp

# automake/autoconf
**/.deps/
**/.dirstamp
**/.libs/
**/Makefile
**/Makefile.in
aclocal.m4
autom4te.cache/
m4/*
**/!README
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1
test-driver

# Test binaries
tests/test_*
!tests/test_*.[ch]

#Ingore all markdown and class files
*.md
**/*.class
LICENSE
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* text=auto
*.conf text eol=lf
*.css text
*.html text
*.ico -text
*.jpg -text
*.js text
*.json text
*.mjs text
*.sh text eol=lf
*.txt text
*.yaml text
34 changes: 34 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
# Add reviewers
reviewers:
- "MaxWaldorf"

- package-ecosystem: "docker" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "MaxWaldorf"

- package-ecosystem: "npm" # See documentation for possible values
directory: "/portal" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "MaxWaldorf"

- package-ecosystem: "yarn" # See documentation for possible values
directory: "/portal" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "MaxWaldorf"
59 changes: 59 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build Main Docker Image

# Controls when the workflow will run
on:
push:
tags:
- 'v*'
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
permissions:
contents: read
packages: write

jobs:
release:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5

with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.x
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ github.event.repository.default_branch != github.ref }}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
60 changes: 60 additions & 0 deletions .github/workflows/docker-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build Dev Docker Image

# Controls when the workflow will run
on:
schedule:
- cron: '0 0 * * *'
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
permissions:
contents: read
packages: write

jobs:
release:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=schedule,pattern=testing
type=raw,value=testing
flavor: |
latest=false
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Specific
**/.env
**/.parcel-cache/*
**/dist/*
**/node_modules/*

# Logs
logs
*.log
Expand Down
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Base image for Node.js applications
ARG NODE_BASE_IMAGE=stable-alpine
FROM nginx:${NODE_BASE_IMAGE}

ARG APPLICATION="keygen-sh-ssp"
ARG BUILD_RFC3339="2024-08-30T20:00:00Z"
ARG REVISION="local"
ARG DESCRIPTION="Fully Packaged Self-Service Portal for Keygen.sh with keycloak SSO"
ARG PACKAGE="flcontainers/keygen-sh-ssp"
ARG VERSION="0.1.0"

LABEL org.opencontainers.image.ref.name="${PACKAGE}" \
org.opencontainers.image.created=$BUILD_RFC3339 \
org.opencontainers.image.authors="MaxWaldorf" \
org.opencontainers.image.documentation="https://github.com/${PACKAGE}/README.md" \
org.opencontainers.image.description="${DESCRIPTION}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.source="https://github.com/${PACKAGE}" \
org.opencontainers.image.revision=$REVISION \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.url="https://hub.docker.com/r/${PACKAGE}/"

# Set production for nodejs
ENV NODE_ENV=production

# node app directory
RUN mkdir -p /app/node/portal

# Install nginx
RUN apk add --no-cache nodejs yarn

# Build Portal
WORKDIR /app/node/portal
COPY portal/ .
RUN yarn

# Change rights
#RUN chown www-data:www-data -R /app/node

# Copy Nginx configuration file
COPY nginx/proxy.conf /etc/nginx/conf.d/default.conf

# Copy a custom startup script
COPY script/startup.sh /startup.sh
RUN chmod +x /startup.sh

WORKDIR /app/portal
#USER www-data

EXPOSE 80
CMD ["/startup.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Keygen LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
# keygen-sh-ssp
Fully Packaged Self-Service Portal for Keygen.sh with keycloak SSO
# Keygen Self-Service Portal
(with Keycloak OpenID authentication)

This is based on an example made by the keygen.sh team [here](https://github.com/keygen-sh/example-react-licensing-portal)...

The portal offers the following functionality:

- License information e.g. expiration date.
- Machine deactivation.
- Protection behind SSO Portal
- Env variables

## Env Variables
_Note: Mandatory varibales marked with *_

__Keycloak data:__
- KEYCLOAK_ID * (Client ID. Note: client must be public)
- KEYCLOAK_REALM * (Realm name)
- KEYCLOAK_URL * (URL of the server) / e.g. https://kc.myserver.org/

__Keygen data:__
- KEYGEN_URL * (URL of the server) / e.g. https://key.myserver.org
- KEYGEN_ACCOUNT_ID * (Keygen account Id)
- KEYGEN_TOKEN * (admin -bearer- token)

__Other data:__
- DOMAIN * (domain of the ssp portal) / e.g. my-domain.com:port (port if required)
- REQUEST_EMAIL (Support Email for license request)

Note: You can use a local .env at root of the application or container variables...
17 changes: 17 additions & 0 deletions nginx/proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;

location /api/ {
proxy_pass http://localhost:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location / {
root /app/node/portal/dist;
index index.html;
}
}
Loading

0 comments on commit 9cc1816

Please sign in to comment.