From 4d8fc5200a287cab7dbe2a9248e8fa65bb4a3e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Sat, 31 May 2025 10:14:28 -0300 Subject: [PATCH] improving build steps --- .env.example | 3 +++ OpenCand.UI.dockerfile | 26 ++++++++++++++++++++++++++ index.html | 3 +-- src/config/api.ts | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .env.example create mode 100644 OpenCand.UI.dockerfile diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..eb3b95f --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +# OpenCand API Configuration +# The base URL for the OpenCand API +VITE_API_BASE_URL=https://api.example.com diff --git a/OpenCand.UI.dockerfile b/OpenCand.UI.dockerfile new file mode 100644 index 0000000..4fa9021 --- /dev/null +++ b/OpenCand.UI.dockerfile @@ -0,0 +1,26 @@ +# ─── Stage 1: Build ─────────────────────────────────────────────────────── +FROM node:slim AS builder +WORKDIR /app + +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +COPY . . + +ARG VITE_API_BASE_URL +ENV VITE_API_BASE_URL=${VITE_API_URL} + +RUN yarn build + +# ─── Stage 2: Serve ──────────────────────────────────────────────────────── +FROM nginx:stable-alpine +# Remove default nginx html +RUN rm -rf /usr/share/nginx/html/* +# Copy our built files into nginx’s html folder +COPY --from=builder /app/dist /usr/share/nginx/html + +# (Optional) If you need any custom nginx.conf, COPY it here— +# e.g. COPY nginx.conf /etc/nginx/nginx.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/index.html b/index.html index e4b78ea..e31f407 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,8 @@ - - Vite + React + TS + OpenCand
diff --git a/src/config/api.ts b/src/config/api.ts index 0f1aa53..895b815 100644 --- a/src/config/api.ts +++ b/src/config/api.ts @@ -1,6 +1,6 @@ // API configuration export const API_CONFIG = { - baseUrl: import.meta.env.VITE_API_BASE_URL || 'https://api.opencand.com', + baseUrl: import.meta.env.VITE_API_BASE_URL || 'API_BASE_URL_NOT_SET', timeout: 30000, // 30 seconds } as const;