Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/publish-web-app-serve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish web app serve

on:
workflow_dispatch:
push:
branches:
- develop
- feature/add-web-app-serve

permissions:
packages: write

jobs:
publish_image:
name: Publish Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Publish web-app-serve
uses: toggle-corp/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
82 changes: 0 additions & 82 deletions .github/workflows/publish_docker.yml

This file was deleted.

47 changes: 16 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,37 @@ FROM node:20-bookworm AS dev
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
git bash g++ make \
&& rm -rf /var/lib/apt/lists/*

RUN corepack enable
&& rm -rf /var/lib/apt/lists/* \
# NOTE: yarn > 1.22.19 breaks yarn-install invoked by pnpm
&& npm install -g [email protected] [email protected] --force \
&& git config --global --add safe.directory /code

WORKDIR /code
RUN git config --global --add safe.directory /code


COPY package.json pnpm-lock.yaml /code/
RUN corepack prepare --activate
# RUN npm install -g pnpm

# RUN pnpm install



# -------------------------- Nginx - Builder --------------------------------
FROM dev AS nginx-build
FROM dev AS web-app-serve-build

COPY package.json pnpm-lock.yaml /code/

RUN corepack prepare --activate

RUN pnpm install

COPY . .
COPY . /code/

# # Build variables (Requires backend pulled)
ENV APP_TITLE=APP_TITLE_PLACEHOLDER
ENV APP_GRAPHQL_ENDPOINT=APP_GRAPHQL_ENDPOINT_PLACEHOLDER
ENV APP_TITLE=CMS
ENV APP_GRAPHQL_ENDPOINT=http://localhost:8001/graphql/
ENV APP_GRAPHQL_CODEGEN_ENDPOINT=./backend/schema.graphql

RUN pnpm generate:type && pnpm build
RUN pnpm generate:type && WEB_APP_SERVE_ENABLED=true pnpm build
# RUN pnpm build

# ---------------------------------------------------------------------------
FROM nginx:1 AS nginx-serve
# ---------------------------------------------------------------------
FROM ghcr.io/toggle-corp/web-app-serve:v0.1.2 AS web-app-serve

LABEL maintainer="Togglecorp Dev"
LABEL org.opencontainers.image.source="https://github.com/toggle-corp"
LABEL org.opencontainers.image.source="https://github.com/my-org/my-best-dashboard"
LABEL org.opencontainers.image.authors="my-email@company.com"

COPY ./nginx-serve/apply-config.sh /docker-entrypoint.d/
COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template
COPY --from=nginx-build /code/build /code/build

# NOTE: Used by apply-config.sh
# Env for apply-config script
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
ENV APPLY_CONFIG__DESTINATION_DIRECTORY=/usr/share/nginx/html/
ENV APPLY_CONFIG__OVERWRITE_DESTINATION=true

COPY --from=web-app-serve-build /code/build "$APPLY_CONFIG__SOURCE_DIRECTORY"
23 changes: 19 additions & 4 deletions env.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import {
defineConfig,
overrideDefineForWebAppServe,
Schema,
} from '@julr/vite-plugin-validate-env';

const webAppServeEnabled = process.env.WEB_APP_SERVE_ENABLED?.toLowerCase() === 'true';

if (webAppServeEnabled) {
// eslint-disable-next-line no-console
console.warn('Building application for web-app-serve');
}
const overrideDefine = webAppServeEnabled
? overrideDefineForWebAppServe
: undefined;

export default defineConfig({
// NOTE: We need to replace with URL
APP_GRAPHQL_ENDPOINT: Schema.string(),
overrideDefine,
validator: 'builtin',
schema: {
// NOTE: We need to replace with URL
APP_GRAPHQL_ENDPOINT: Schema.string(),

// NOTE: It is not used for now
APP_TITLE: Schema.string(),
// NOTE: It is not used for now
APP_TITLE: Schema.string(),
},
});
37 changes: 0 additions & 37 deletions nginx-serve/apply-config.sh

This file was deleted.

17 changes: 0 additions & 17 deletions nginx-serve/nginx.conf.template

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@apollo/client": "^3.11.8",
"@graphql-typed-document-node/core": "^3.2.0",
"@julr/vite-plugin-validate-env": "^1.1.1",
"@julr/vite-plugin-validate-env": "git+https://github.com/toggle-corp/vite-plugin-validate-env#v2.2.0-tc.1",
"@togglecorp/fujs": "^2.0.0",
"@togglecorp/toggle-form": "^2.0.4",
"@togglecorp/toggle-ui": "^0.18.3",
Expand Down Expand Up @@ -73,7 +73,7 @@
"stylelint": "^16.2.1",
"stylelint-config-concentric": "^2.0.2",
"stylelint-config-recommended": "^14.0.0",
"stylelint-no-unused-selectors": "git+https://github.com/toggle-corp/stylelint-no-unused-selectors#feature/yarn-to-pnpm",
"stylelint-no-unused-selectors": "git+https://github.com/toggle-corp/stylelint-no-unused-selectors#e0831e1",
"stylelint-value-no-unknown-custom-properties": "^6.0.1",
"typescript": "^5.0.4",
"vite": "^5.1.5",
Expand Down
Loading
Loading