Skip to content

Commit

Permalink
Merge pull request #50 from tawoe/container
Browse files Browse the repository at this point in the history
Reformat Copyright notice / Add container run script
  • Loading branch information
simonredfern authored May 15, 2024
2 parents 941ec41 + bbf6268 commit 4214d2a
Show file tree
Hide file tree
Showing 47 changed files with 115 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ server-dist
coverage
*.local
.env
.env_*

/cypress/videos/
/cypress/screenshots/
Expand Down
14 changes: 12 additions & 2 deletions Dockerfiles/Dockerfile_frontend
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@ FROM node:lts-bullseye as builder
ADD .. /home/node/app/
WORKDIR /home/node/app
# Install the dependencies
COPY Dockerfiles/frontend_build.env /home/node/app/.env
RUN npm install
RUN npm run build

FROM golang:bookworm as gobuilder

WORKDIR /usr/src/app
COPY Dockerfiles/prestart.go ./main.go
COPY Dockerfiles/go.mod ./

RUN go build -v -o /usr/src/app/prestart

FROM registry.access.redhat.com/ubi9/nginx-120
USER 0
RUN dnf update -y
RUN chown -R 1001 /var/log/nginx
ADD Dockerfiles/nginx.conf "${NGINX_DEFAULT_CONF_PATH}"
COPY --from=builder /home/node/app/dist /opt/app-root/src
COPY --from=gobuilder /usr/src/app/prestart /bin/prestart

RUN chgrp -R 0 /opt/app-root/src/ && chmod -R g+rwX /opt/app-root/src/
USER 1001
CMD ["nginx", "-g", "daemon off;"]

CMD /bin/prestart ; nginx -g "daemon off;"



Expand Down
4 changes: 4 additions & 0 deletions Dockerfiles/frontend_build.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_OBP_API_HOST=VITE_OBP_API_HOST
VITE_OBP_API_MANAGER_HOST=VITE_OBP_API_MANAGER_HOST
VITE_OBP_API_VERSION=v5.1.0

3 changes: 3 additions & 0 deletions Dockerfiles/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module GoHelpers

go 1.21
76 changes: 76 additions & 0 deletions Dockerfiles/prestart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package main

import (
"log"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
)

func main() {
config := []string{"VITE_OBP_API_HOST", "VITE_OBP_API_MANAGER_HOST"}
configMap := make(map[string]string)

for _, key := range config {
rawURL := os.Getenv(key)
if rawURL == "" {
continue
}
cleanURL := checkURL(rawURL)
configMap[key] = cleanURL
}

dir := "/opt/app-root/src/assets"
pattern := "index-.*\\.js$"

re, err := regexp.Compile(pattern)
if err != nil {
log.Fatal(err)
}

files, err := os.ReadDir(dir)
if err != nil {
log.Fatal(err)
}

for _, file := range files {
if re.MatchString(file.Name()) {
filePath := filepath.Join(dir, file.Name())
content, err := os.ReadFile(filePath)
if err != nil {
panic(err)
}
modifiedContent := string(content)
for old, new := range configMap {
modifiedContent = strings.Replace(modifiedContent, old, new, -1)
}
err = os.WriteFile(filePath, []byte(modifiedContent), 0644)
if err != nil {
panic(err)
}
}
}

}

func checkURL(rawURL string) string {

parsedURL, err := url.Parse(rawURL)
if err != nil {
log.Fatal(err)
}

validURL := regexp.MustCompile(`^https?:\/\/[^\s/$.?#].[^\s]*$`)
if !validURL.MatchString(rawURL) {
log.Fatal("Invalid URL or potential code injection detected")
}

cleanURL := &url.URL{
Scheme: parsedURL.Scheme,
Host: parsedURL.Host,
Path: parsedURL.Path,
}
return cleanURL.String()
}
7 changes: 3 additions & 4 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export {}

declare module '@vue/runtime-core' {
export interface GlobalComponents {
Collections: typeof import('./src/components/Collections.vue')['default']
Content: typeof import('./src/components/Content.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAside: typeof import('element-plus/es')['ElAside']
ElBacktop: typeof import('element-plus/es')['ElBacktop']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
Expand All @@ -32,10 +32,9 @@ declare module '@vue/runtime-core' {
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElRow: typeof import('element-plus/es')['ElRow']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']
GlossarySearchNav: typeof import('./src/components/GlossarySearchNav.vue')['default']
HeaderNav: typeof import('./src/components/HeaderNav.vue')['default']
Menu: typeof import('./src/components/Menu.vue')['default']
Expand Down
1 change: 0 additions & 1 deletion server/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/controllers/CallbackController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/controllers/ConnectController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/controllers/RequestController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/controllers/StatusController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/controllers/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/middlewares/OauthAccessTokenMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/middlewares/OauthRequestTokenMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/services/OBPClientService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion server/services/OauthInjectedService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
3 changes: 1 addition & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
1 change: 0 additions & 1 deletion src/assets/base.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/assets/element-plus-override.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/assets/highlightjs-override.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
3 changes: 1 addition & 2 deletions src/components/Collections.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/Content.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/GlossarySearchNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/HeaderNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/MessageDocsSearchNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/Preview.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script setup lang="ts">
Expand Down
3 changes: 1 addition & 2 deletions src/components/SearchNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--
- /**
- Open Bank Project - API Explorer II
- Copyright (C) 2023-2024, TESOBE GmbH
-
Expand All @@ -23,7 +22,7 @@
-
- This product includes software developed at
- TESOBE (http://www.tesobe.com/)
- */
-
-->

<script lang="ts">
Expand Down
1 change: 0 additions & 1 deletion src/language/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/obp/api-version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
1 change: 0 additions & 1 deletion src/obp/common-functions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* *
* Open Bank Project - API Explorer II
* Copyright (C) 2023-2024, TESOBE GmbH
*
Expand Down
Loading

0 comments on commit 4214d2a

Please sign in to comment.