Skip to content

Commit

Permalink
Server Side Rendering (#102)
Browse files Browse the repository at this point in the history
* add title generation

Signed-off-by: Mirko Mollik <[email protected]>

* fix: update angular core

Signed-off-by: Mirko Mollik <[email protected]>

* fix: update angular core

Signed-off-by: Mirko Mollik <[email protected]>

* fix: update angular material

Signed-off-by: Mirko Mollik <[email protected]>

* fix: ssr

Signed-off-by: Mirko Mollik <[email protected]>

* add docker build image

Signed-off-by: Mirko Mollik <[email protected]>

* optimize og integration for seo

Signed-off-by: Mirko Mollik <[email protected]>

---------

Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
cre8 authored Oct 8, 2024
1 parent ef279c4 commit 082082d
Show file tree
Hide file tree
Showing 34 changed files with 1,501 additions and 1,067 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ permissions:
contents: read
pages: write
id-token: write
packages: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
Expand Down Expand Up @@ -107,3 +108,37 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

docker:
# only run on the main branch
if: github.ref == 'refs/heads/main'
needs: [validate, build]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: viewer/
push: true
tags: ghcr.io/${{ github.repository_owner }}/wallet-agent-overview:latest
2 changes: 2 additions & 0 deletions viewer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
36 changes: 36 additions & 0 deletions viewer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Stage 1: Build the Angular application
FROM node:18-alpine AS build

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json files
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy the rest of the application code
COPY . .

# Build the Angular application
RUN npm run build:ssr

# Stage 2: Serve the application using Node.js
FROM node:18-alpine

# Set the working directory
WORKDIR /app

# Copy the built application from the previous stage
COPY --from=build /app/dist /app/dist

# Install only production dependencies
COPY package*.json ./
RUN npm install --only=production

# Expose the port the app runs on
EXPOSE 4000

# Start the application
CMD ["npm", "run", "serve:ssr:viewer"]
28 changes: 27 additions & 1 deletion viewer/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
"src/styles.scss",
"node_modules/prismjs/themes/prism-okaidia.css"
],
"scripts": ["node_modules/prismjs/prism.js"]
"scripts": ["node_modules/prismjs/prism.js"],
"server": "src/main.server.ts",
"prerender": true,
"ssr": {
"entry": "server.ts"
}
},
"configurations": {
"production": {
Expand All @@ -48,6 +53,27 @@
],
"outputHashing": "all"
},
"ssr": {
"budgets": [
{
"type": "initial",
"maximumWarning": "1mb",
"maximumError": "2mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ssr.ts"
}
]
},
"development": {
"optimization": false,
"extractLicenses": false,
Expand Down
Loading

0 comments on commit 082082d

Please sign in to comment.