Skip to content

Commit 4aa4a85

Browse files
committed
feat(web-app-serve): configure web app serve
1 parent 6550520 commit 4aa4a85

File tree

6 files changed

+95
-2
lines changed

6 files changed

+95
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish web app serve
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- develop
8+
- feature/add-web-app-serve # NOTE Delete me later
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+
20+
- name: Publish web-app-serve
21+
uses: toggle-corp/[email protected]
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,45 @@ RUN apt-get update -y \
77
&& npm install -g [email protected] [email protected] --force \
88
&& git config --global --add safe.directory /code
99

10+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
11+
12+
ENV PNPM_HOME="/pnpm"
13+
ENV PATH="$PNPM_HOME:$PATH"
14+
RUN --mount=type=bind,source=package.json,target=package.json \
15+
corepack install && corepack enable
16+
1017
WORKDIR /code
18+
19+
# -------------------------- Builder ----------------------------------
20+
FROM dev AS builder
21+
22+
COPY package.json pnpm-lock.yaml /code/
23+
24+
RUN corepack prepare --activate
25+
26+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
27+
--mount=type=bind,source=package.json,target=package.json \
28+
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
29+
pnpm install --frozen-lockfile
30+
31+
COPY . /code/
32+
33+
# -------------------------- Web app build -----------------------------
34+
35+
FROM builder AS web-app-serve-build
36+
37+
ENV APP_TITLE=TC-Unified-Notes
38+
ENV APP_UNIFIED_API_ENDPOINT=http://192.168.88.52:8020/
39+
40+
41+
RUN WEB_APP_SERVE_ENABLED=true pnpm build
42+
43+
# Final image using web-app-serve
44+
FROM ghcr.io/toggle-corp/web-app-serve:v0.1.2 AS web-app-serve
45+
46+
LABEL maintainer="Togglecorp"
47+
LABEL org.opencontainers.image.source="https://github.com/toggle-corp/tc-unified-notes"
48+
49+
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
50+
51+
COPY --from=web-app-serve-build /code/build "$APPLY_CONFIG__SOURCE_DIRECTORY"

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: tc-unified-notes
2+
13
services:
24
react:
35
build:

env.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
import {
22
defineConfig,
3+
overrideDefineForWebAppServe,
34
Schema,
45
} from '@julr/vite-plugin-validate-env';
56

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+
const overrideDefine = webAppServeEnabled
13+
? overrideDefineForWebAppServe
14+
: undefined;
15+
616
export default defineConfig({
7-
APP_TITLE: Schema.string(),
8-
APP_UNIFIED_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
17+
overrideDefine,
18+
validator: 'builtin',
19+
schema: {
20+
APP_TITLE: Schema.string(),
21+
APP_UNIFIED_API_ENDPOINT: Schema.string({ format: 'url', protocol: true, tld: false }),
22+
},
923
});

web-app-serve/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

web-app-serve/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: tc-unified-notes-serve
2+
3+
services:
4+
web-app-serve:
5+
build:
6+
context: ../
7+
target: web-app-serve
8+
environment:
9+
APPLY_CONFIG__ENABLE_DEBUG: true
10+
env_file: .env
11+
ports:
12+
- '8050:80'

0 commit comments

Comments
 (0)