improving build steps

This commit is contained in:
José Henrique 2025-05-31 10:14:28 -03:00
parent 3dc522384d
commit 4d8fc5200a
4 changed files with 31 additions and 3 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
# OpenCand API Configuration
# The base URL for the OpenCand API
VITE_API_BASE_URL=https://api.example.com

26
OpenCand.UI.dockerfile Normal file
View File

@ -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 nginxs 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;"]

View File

@ -2,9 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>OpenCand</title>
</head>
<body>
<div id="root"></div>

View File

@ -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;