diff --git a/Dockerfile.stg b/Dockerfile.stg new file mode 100644 index 0000000..38fbef4 --- /dev/null +++ b/Dockerfile.stg @@ -0,0 +1,18 @@ +FROM node:18.20.4-alpine3.20 + +WORKDIR /app + +RUN npm install -g pnpm +COPY package*.json . +COPY pnpm-lock.yaml . +RUN pnpm install --prefer-offline=true --frozen-lockfile=true +RUN npm i -g serve + +COPY . . +ENV NODE_ENV=stg + +RUN pnpm build + +EXPOSE 3000 + +CMD [ "serve", "-s", "dist" ] diff --git a/docker-compose.yml b/docker-compose.yml index 716f894..7518680 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: image: fuware-fe build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.stg restart: always ports: - 16001:3000 diff --git a/src/api/url.js b/src/api/url.js index c484784..f8af89a 100644 --- a/src/api/url.js +++ b/src/api/url.js @@ -1,15 +1,17 @@ -export const POST_LOGIN = '/api/auth/login' -export const POST_LOGOUT = '/api/auth/logout' -export const POST_REFRESH = '/api/auth/refresh' -export const GET_USER_PROFILE = '/api/user/me' -export const PUT_UPDATE_USER_PROFILE = '/api/user/update-profile' +const BASE_URL = '' + +export const POST_LOGIN = `${BASE_URL}/api/auth/login` +export const POST_LOGOUT = `${BASE_URL}/api/auth/logout` +export const POST_REFRESH = `${BASE_URL}/api/auth/refresh` +export const GET_USER_PROFILE = `${BASE_URL}/api/user/me` +export const PUT_UPDATE_USER_PROFILE = `${BASE_URL}/api/user/update-profile` /** * House API */ -export const POST_HOUSE_CREATE = '/api/house/create' +export const POST_HOUSE_CREATE = `${BASE_URL}/api/house/create` export const GET_HOUSES_LIST = ({ page, pageSize }) => - `/api/house/all?page=${page}&pageSize=${pageSize}` -export const GET_HOUSE_DETAIL = (id) => `/api/house/${id}` -export const PUT_UPDATE_HOUSE = '/api/house/update' -export const DEL_DELETE_HOUSE = (id) => `/api/house/delete/${id}` + `${BASE_URL}/api/house/all?page=${page}&pageSize=${pageSize}` +export const GET_HOUSE_DETAIL = (id) => `${BASE_URL}/api/house/${id}` +export const PUT_UPDATE_HOUSE = `${BASE_URL}/api/house/update` +export const DEL_DELETE_HOUSE = (id) => `${BASE_URL}/api/house/delete/${id}` diff --git a/vite.config.js b/vite.config.js index 4f7f0fd..c6ec889 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,44 +10,7 @@ export default defineConfig(({ mode }) => { // eslint-disable-next-line no-undef const env = loadEnv(mode, process.cwd(), '') - // production - if (env.NODE_ENV === 'production') { - return { - resolve: { - alias: { - '@': path.resolve(_dirname, './src'), - '@lang': path.resolve(_dirname, './src/lang'), - '@api': path.resolve(_dirname, './src/api'), - '@hooks': path.resolve(_dirname, './src/hooks'), - '@pages': path.resolve(_dirname, './src/pages'), - '@components': path.resolve(_dirname, './src/components'), - '@routes': path.resolve(_dirname, './src/routes'), - '@utils': path.resolve(_dirname, './src/utils'), - '@assets': path.resolve(_dirname, './src/assets'), - '@context': path.resolve(_dirname, './src/context'), - }, - }, - plugins: [react()], - css: { - preprocessorOptions: { - scss: { - additionalData: '@import "./src/_mantine";', - }, - }, - }, - server: { - https: false, - host: false, - port: 5001, - strictPort: true, - watch: { - usePolling: true, - }, - }, - } - } - - return { + const config_sv = { resolve: { alias: { '@': path.resolve(_dirname, './src'), @@ -70,6 +33,44 @@ export default defineConfig(({ mode }) => { }, }, }, + } + + // production + if (env.NODE_ENV === 'production') { + return { + ...config_sv, + server: { + https: false, + host: false, + port: 5001, + strictPort: true, + watch: { + usePolling: true, + }, + }, + } + } + + if (env.NODE_ENV === 'stg') { + return { + ...config_sv, + server: { + https: false, + host: false, + port: 5001, + strictPort: true, + watch: { + usePolling: true, + }, + proxy: { + '/api': 'https://stg-be.samliu.io.vn', + }, + }, + } + } + + return { + ...config_sv, server: { https: false, host: true,