Skip to content

Commit 633228e

Browse files
committed
Add web app serve for alpha deployment
1 parent 7b4aec6 commit 633228e

File tree

27 files changed

+296
-654
lines changed

27 files changed

+296
-654
lines changed

.dockerignore

Lines changed: 3 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,4 @@
1-
# Swap files
2-
*.swp
3-
4-
# Byte-compiled / optimized / DLL files
5-
__pycache__
6-
*.py[cod]
7-
*$py.class
8-
9-
# C extensions
10-
*.so
11-
12-
# Distribution / packaging
13-
.Python
14-
env
15-
build
16-
develop-eggs
17-
dist
18-
downloads
19-
eggs
20-
.eggs
21-
lib
22-
lib64
23-
parts
24-
sdist
25-
var
26-
*.egg-info
27-
.installed.cfg
28-
*.egg
29-
30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
37-
pip-log.txt
38-
pip-delete-this-directory.txt
39-
40-
# Unit test / coverage reports
41-
htmlcov
42-
.tox
43-
.coverage
44-
.coverage.*
45-
.cache
46-
nosetests.xml
47-
coverage.xml
48-
*,cover
49-
.hypothesis
50-
51-
# Translations
52-
*.mo
53-
*.pot
54-
55-
# Django stuff:
56-
*.log
57-
58-
# Sphinx documentation
59-
docs/_build
60-
61-
# PyBuilder
62-
target
63-
64-
#Ipython Notebook
65-
.ipynb_checkpoints
66-
67-
# SASS cache
68-
.sass-cache
69-
media_test
70-
71-
# Rope project settings
72-
.ropeproject
73-
74-
# Logs
75-
logs
76-
*.log
77-
npm-debug.log*
78-
yarn-debug.log*
79-
yarn-error.log*
80-
81-
# Runtime data
82-
pids
83-
*.pid
84-
*.seed
85-
*.pid.lock
86-
87-
# Directory for instrumented libs generated by jscoverage/JSCover
88-
lib-cov
89-
90-
# Coverage directory used by tools like istanbul
91-
coverage
92-
93-
# nyc test coverage
94-
.nyc_output
95-
96-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
97-
.grunt
98-
99-
# Bower dependency directory (https://bower.io/)
100-
bower_components
101-
102-
# node-waf configuration
103-
.lock-wscript
104-
105-
# Compiled binary addons (http://nodejs.org/api/addons.html)
106-
build/Release
107-
108-
# Dependency directories
1091
node_modules
110-
jspm_packages
111-
112-
# Typescript v1 declaration files
113-
typings
114-
115-
# Optional npm cache directory
116-
.npm
117-
118-
# Optional eslint cache
119-
.eslintcache
120-
121-
# Optional REPL history
122-
.node_repl_history
123-
124-
# Output of 'npm pack'
125-
*.tgz
126-
127-
# Yarn Integrity file
128-
.yarn-integrity
129-
130-
# dotenv environment variables file
131-
.env
132-
.env*
133-
134-
# Sensitive Deploy Files
135-
deploy/eb/
136-
data/
137-
138-
# tox
139-
./.tox
140-
141-
backend/
142-
!backend/schema.graphql
143-
geographical_data/
2+
dist
3+
.git
4+
.vscode
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish web app serve
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- develop
8+
- feature/web-app-serve # TODO: Delete me
9+
10+
permissions:
11+
packages: write
12+
13+
jobs:
14+
publish_image:
15+
name: Publish Docker Image
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
22+
- name: Publish web-app-serve
23+
uses: toggle-corp/[email protected]
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -------------------------- Dev ---------------------------------------
22

3-
FROM node:18-bullseye AS dev
3+
FROM node:20-bookworm AS dev
44

55
RUN apt-get update -y \
66
&& apt-get install -y --no-install-recommends \
@@ -15,7 +15,6 @@ WORKDIR /code
1515

1616
RUN git config --global --add safe.directory /code
1717

18-
1918
# -------------------------- Builder ---------------------------------------
2019
FROM dev AS builder
2120

@@ -27,32 +26,26 @@ RUN pnpm install
2726

2827
COPY . /code/
2928

30-
# -------------------------- Nginx - Builder --------------------------------
31-
FROM builder AS nginx-build
29+
FROM builder AS web-app-serve-build
3230

3331
# Dynamic configs. Can be changed with containers. (Placeholder values)
34-
ENV APP_TITLE=APP_TITLE_PLACEHOLDER
35-
ENV APP_ENVIRONMENT=APP_ENVIRONMENT_PLACEHOLDER
36-
ENV APP_MAPBOX_ACCESS_TOKEN=APP_MAPBOX_ACCESS_TOKEN_PLACEHOLDER
37-
ENV APP_GOOGLE_ANALYTICS_ID=APP_GOOGLE_ANALYTICS_ID_PLACEHOLDER
38-
ENV APP_GRAPHQL_API_ENDPOINT=https://APP-GRAPHQL-API-ENDPOINT-PLACEHOLDER.COM/
39-
ENV APP_HCAPTCHA_SITEKEY=APP_HCAPTCHA_SITEKEY_PLACEHOLDER
32+
ENV APP_TITLE=Alerthub
33+
ENV APP_ENVIRONMENT=production
34+
ENV APP_MAPBOX_ACCESS_TOKEN=pk.ey
35+
ENV APP_GOOGLE_ANALYTICS_ID=G-PZ
36+
ENV APP_GRAPHQL_API_ENDPOINT=https://my-best-dashboard.com/graphql/
37+
ENV APP_HCAPTCHA_SITEKEY=100--ff
4038

4139
# Build variables (Requires backend pulled)
4240
ENV APP_GRAPHQL_CODEGEN_ENDPOINT=./backend/schema.graphql
4341

44-
RUN pnpm generate && pnpm build
42+
RUN pnpm generate && WEB_APP_SERVE_ENABLED=true
4543

46-
# ---------------------------------------------------------------------------
47-
FROM nginx:1 AS nginx-serve
44+
FROM ghcr.io/toggle-corp/web-app-serve:v0.1.2 AS web-app-serve
4845

4946
LABEL maintainer="IFRC"
50-
LABEL org.opencontainers.image.source="github.com/IFRCGo/alert-hub-web-app"
51-
52-
COPY ./nginx-serve/apply-config.sh /docker-entrypoint.d/
53-
COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template
54-
COPY --from=nginx-build /code/build /code/build
47+
LABEL org.opencontainers.image.source="https://github.com/IFRCGo/alert-hub-web-app"
5548

5649
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
57-
ENV APPLY_CONFIG__DESTINATION_DIRECTORY=/usr/share/nginx/html/
58-
ENV APPLY_CONFIG__OVERWRITE_DESTINATION=true
50+
51+
COPY --from=web-app-serve-build /code/build "$APPLY_CONFIG__SOURCE_DIRECTORY"

docker-compose-with-backend.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# NOTE: `../` refers to the web-app folder, relative to `./backend/docker-compose.yml` (the main Docker Compose file).
2+
name: alerthub
3+
24
services:
35
react:
46
build:

env.ts

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
1-
import { defineConfig, Schema } from '@julr/vite-plugin-validate-env';
1+
import {
2+
defineConfig,
3+
overrideDefineForWebAppServe,
4+
Schema,
5+
} from '@julr/vite-plugin-validate-env';
26

3-
export default defineConfig({
4-
// Used in vite
5-
APP_GOOGLE_ANALYTICS_ID: Schema.string.optional(),
7+
const webAppServeEnabled = process.env.WEB_APP_SERVE_ENABLED?.toLowerCase() === 'true';
8+
if (webAppServeEnabled) {
9+
// eslint-disable-next-line no-console
10+
console.warn('Building application for web-app-serve');
11+
}
12+
13+
const overrideDefine = webAppServeEnabled
14+
? overrideDefineForWebAppServe
15+
: undefined;
616

7-
// Used in application
8-
APP_TITLE: Schema.string.optional(), // NOTE: not used right now
9-
APP_ENVIRONMENT: (key, value) => {
10-
// NOTE: APP_ENVIRONMENT_PLACEHOLDER is meant to be used with image builds
11-
// The value will be later replaced with the actual value
12-
const regex = /^production|staging|testing|alpha-\d+|development|APP_ENVIRONMENT_PLACEHOLDER$/;
13-
const valid = !!value && (value.match(regex) !== null);
14-
if (!valid) {
15-
throw new Error(`Value for environment variable "${key}" must match regex "${regex}", instead received "${value}"`);
16-
}
17-
if (value === 'APP_ENVIRONMENT_PLACEHOLDER') {
18-
console.warn(`Using ${value} for app environment. Make sure to not use this for builds without nginx-serve`)
19-
}
20-
return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development' | 'APP_ENVIRONMENT_PLACEHOLDER');
21-
},
22-
APP_GRAPHQL_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
23-
APP_MAPBOX_ACCESS_TOKEN: Schema.string(),
17+
export default defineConfig({
18+
overrideDefine,
19+
validator: 'builtin',
20+
schema: {
21+
APP_GOOGLE_ANALYTICS_ID: Schema.string.optional(),
22+
APP_TITLE: Schema.string.optional(), // NOTE: not used right now
23+
APP_ENVIRONMENT: (key, value) => {
24+
// NOTE: APP_ENVIRONMENT_PLACEHOLDER is meant to be used with image builds
25+
// The value will be later replaced with the actual value
26+
const regex = /^production|staging|testing|alpha-\d+|development|APP_ENVIRONMENT_PLACEHOLDER$/;
27+
const valid = !!value && (value.match(regex) !== null);
28+
if (!valid) {
29+
throw new Error(`Value for environment variable "${key}" must match regex "${regex}", instead received "${value}"`);
30+
}
31+
if (value === 'APP_ENVIRONMENT_PLACEHOLDER') {
32+
console.warn(`Using ${value} for app environment. Make sure to not use this for builds without nginx-serve`)
33+
}
34+
return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development' | 'APP_ENVIRONMENT_PLACEHOLDER');
35+
},
36+
APP_GRAPHQL_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
37+
APP_MAPBOX_ACCESS_TOKEN: Schema.string(),
2438

25-
APP_HCAPTCHA_SITEKEY: Schema.string.optional(),
39+
APP_HCAPTCHA_SITEKEY: Schema.string.optional(),
2640

27-
// Used in codegen
28-
APP_GRAPHQL_CODEGEN_ENDPOINT: Schema.string(), // NOTE: this is both url and file path
41+
// Used in codegen
42+
APP_GRAPHQL_CODEGEN_ENDPOINT: Schema.string(), // NOTE: this is both url and file path
2943

30-
// Used in application, automatically injected by vite
31-
APP_COMMIT_HASH: Schema.string.optional(),
32-
APP_VERSION: Schema.string.optional(),
33-
})
44+
// Used in application, automatically injected by vite
45+
APP_COMMIT_HASH: Schema.string.optional(),
46+
APP_VERSION: Schema.string.optional(),
47+
},
48+
});

nginx-serve/apply-config.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

nginx-serve/helm/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

nginx-serve/helm/Chart.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)