Skip to content

Commit

Permalink
Added initial website.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielscholl committed Sep 24, 2024
1 parent 138e3b2 commit 23cd34f
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 21 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
name: Build and publish Docker image for web

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: ['master']
paths:
- 'web/**'
workflow_dispatch:

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-web

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: web
file: web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

175 changes: 175 additions & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
23 changes: 11 additions & 12 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Use the official Bun image
FROM oven/bun:latest

# Set the working directory in the container
WORKDIR /app

# Copy package.json and bun.lockb (if exists)
COPY package.json bun.lockb* ./
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# Install dependencies
RUN bun install
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

# Copy the rest of the application code
COPY . .

# Expose port 8000
EXPOSE 8000
# Set environment to production
ENV NODE_ENV=production

# Expose the port your app runs on
EXPOSE 8080

# Start the Bun application
CMD ["bun", "run", "start"]
# Run the app
CMD ["bun", "run", "index.ts"]
15 changes: 15 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# osdu-developer

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.1.29. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file added web/bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions web/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.8"

services:
app:
build: .
ports:
- "8080:8080"
Binary file added web/images/Black logo - no background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/images/Color logo - no background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/images/White logo - no background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/images/browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/images/logo_white_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 38 additions & 9 deletions web/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { serve } from "bun";
import { serve, file } from "bun";

const port = 8000;
const port = 8080;

const html = `
<!DOCTYPE html>
Expand All @@ -10,6 +10,7 @@ const html = `
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OSDU Developer</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="icon" type="image/png" href="images/browser.png">
<style>
body {
background-color: #ffffff;
Expand All @@ -20,6 +21,18 @@ const html = `
.navbar-brand {
color: #ffffff !important;
}
.logo {
width: auto;
height: 33vh; /* Set height to 1/3 of viewport */
margin-bottom: 20px;
}
/* Optionally adjust the container */
.logo-container {
height: 33vh; /* Logo container height 1/3 of viewport */
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
Expand All @@ -28,9 +41,10 @@ const html = `
<span class="navbar-brand mb-0 h1">OSDU Developer</span>
</div>
</nav>
<div class="container mt-5">
<h1 class="text-center" style="color: #01696e;">Welcome to OSDU Developer</h1>
<p class="text-center">This is a simple webpage served by Bun.</p>
<div class="container mt-5 logo-container">
<div class="d-flex justify-content-center">
<img src="images/logo_white_bg.png" alt="OSDU Developer Logo" class="logo">
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
Expand All @@ -39,10 +53,25 @@ const html = `

serve({
port: port,
fetch(req) {
return new Response(html, {
headers: { "Content-Type": "text/html" },
});
async fetch(req) {
const url = new URL(req.url);
if (url.pathname === "/") {
return new Response(html, {
headers: { "Content-Type": "text/html" },
});
} else if (url.pathname === "/images/logo_white_bg.png") {
const imageFile = file("images/logo_white_bg.png");
return new Response(imageFile, {
headers: { "Content-Type": "image/png" },
});
} else if (url.pathname === "/images/browser.png") {
const faviconFile = file("images/browser.png");
return new Response(faviconFile, {
headers: { "Content-Type": "image/png" },
});
} else {
return new Response("Not Found", { status: 404 });
}
},
});

Expand Down
11 changes: 11 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "osdu-developer",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
Loading

0 comments on commit 23cd34f

Please sign in to comment.