build: docker文件优化
This commit is contained in:
parent
c7c774f801
commit
7d34d4ac83
19
Dockerfile
19
Dockerfile
|
@ -14,21 +14,24 @@ RUN npm install -g pnpm
|
||||||
# 构建项目
|
# 构建项目
|
||||||
# 安装生成依赖
|
# 安装生成依赖
|
||||||
FROM base AS prod-deps
|
FROM base AS prod-deps
|
||||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# 基于prod-deps生成的依赖执行构建
|
# 基于prod-deps生成的依赖执行构建
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
## 不适用rimraf,因为rimraf是开发环境依赖
|
||||||
RUN pnpm run build
|
|
||||||
|
|
||||||
# 将prod-deps生成的依赖拷贝到base/$PROJECT_DIR中,开始在builder构建阶段build,最后拷贝build生成的dist到base/$PROJECT_DIR中
|
|
||||||
FROM base AS result
|
|
||||||
COPY --from=prod-deps $PROJECT_DIR/node_modules $PROJECT_DIR/node_modules
|
COPY --from=prod-deps $PROJECT_DIR/node_modules $PROJECT_DIR/node_modules
|
||||||
COPY --from=builder $PROJECT_DIR/dist $PROJECT_DIR/dist
|
# 构建项目 VITE_BASE_URL=/ 为了静态资源assets中文件的路径正确 去掉/api
|
||||||
|
ENV VITE_BASE_URL=/
|
||||||
|
RUN pnpm run build
|
||||||
|
# # 将prod-deps生成的依赖拷贝到base/$PROJECT_DIR中,开始在builder构建阶段build,最后拷贝build生成的dist到base/$PROJECT_DIR中
|
||||||
|
# FROM base AS result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 构建nginx,并且在result之后拷贝dist到nginx中,其中包含了自定义nginx.conf,
|
# 构建nginx,并且在result之后拷贝dist到nginx中,其中包含了自定义nginx.conf,
|
||||||
FROM nginx:alpine as production
|
FROM nginx:alpine as production
|
||||||
ENV PROJECT_DIR=/huaxin-front
|
ENV PROJECT_DIR=/huaxin-front
|
||||||
COPY --from=result $PROJECT_DIR/dist/ /usr/share/nginx/html
|
COPY --from=builder $PROJECT_DIR/dist/ /usr/share/nginx/html
|
||||||
COPY --from=result $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf
|
COPY --from=builder $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf
|
||||||
EXPOSE 80
|
EXPOSE 80
|
|
@ -6,7 +6,7 @@ services:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: result
|
target: production
|
||||||
container_name: huaxin-base-frontend
|
container_name: huaxin-base-frontend
|
||||||
ports:
|
ports:
|
||||||
- '80:80'
|
- '80:80'
|
||||||
|
|
|
@ -91,9 +91,10 @@ export async function dictTypeDelete(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 一次性获取所有的字典类型(不分页) GET /api/system/dict-type/all*/
|
/** 一次性获取所有的字典类型(不分页) GET /api/system/dict-type/all*/
|
||||||
export async function dictTypeGetAll(options?: RequestOptions) {
|
export async function dictTypeGetAll(params: API.DictTypeListParams, options?: RequestOptions) {
|
||||||
return request<API.DictTypeEntity[]>('/api/system/dict-type/all', {
|
return request<API.DictTypeEntity[]>('/api/system/dict-type/all', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
params,
|
||||||
...(options || {}),
|
...(options || {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,10 +264,12 @@ declare namespace API {
|
||||||
field?: string;
|
field?: string;
|
||||||
order?: 'ASC' | 'DESC';
|
order?: 'ASC' | 'DESC';
|
||||||
/** 字典类型名称 */
|
/** 字典类型名称 */
|
||||||
name: string;
|
name?: string;
|
||||||
/** 字典类型code */
|
/** 字典类型code */
|
||||||
code: string;
|
code?: string;
|
||||||
_t?: number;
|
_t?: number;
|
||||||
|
withItems?: boolean;
|
||||||
|
storeCodes?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type DictTypeUpdateParams = {
|
type DictTypeUpdateParams = {
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
const collapsed = ref<boolean>(false);
|
const collapsed = ref<boolean>(false);
|
||||||
// 自定义侧边栏菜单收缩和展开时的宽度
|
// 自定义侧边栏菜单收缩和展开时的宽度
|
||||||
const asiderWidth = computed(() => (collapsed.value ? 80 : 220));
|
const asiderWidth = computed(() => (collapsed.value ? 80 : 220));
|
||||||
const getTheme = computed(() => (layoutSetting.value.navTheme === 'light' ? 'light' : 'dark'));
|
const getTheme = computed(() => (layoutSetting.value.navTheme === 'dark' ? 'dark' : 'light'));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
|
@ -9,9 +9,12 @@ const needCachedKey = [
|
||||||
export const useDictStore = defineStore('dict', () => {
|
export const useDictStore = defineStore('dict', () => {
|
||||||
const dictTypes = ref<API.DictTypeDto[]>([]);
|
const dictTypes = ref<API.DictTypeDto[]>([]);
|
||||||
const getDictTypes = async () => {
|
const getDictTypes = async () => {
|
||||||
dictTypes.value = await Api.systemDictType.dictTypeGetAll();
|
dictTypes.value = await Api.systemDictType.dictTypeGetAll({
|
||||||
|
storeCodes: needCachedKey,
|
||||||
|
withItems: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
getDictTypes();
|
||||||
const getDictItemsByCode = async (code: string): Promise<API.DictItemEntity[]> => {
|
const getDictItemsByCode = async (code: string): Promise<API.DictItemEntity[]> => {
|
||||||
try {
|
try {
|
||||||
const dictType = dictTypes.value.find((item) => item.code === code);
|
const dictType = dictTypes.value.find((item) => item.code === code);
|
||||||
|
|
|
@ -110,9 +110,7 @@ export const useUserStore = defineStore('user', () => {
|
||||||
const afterLogin = async () => {
|
const afterLogin = async () => {
|
||||||
try {
|
try {
|
||||||
const { accountProfile } = Api.account;
|
const { accountProfile } = Api.account;
|
||||||
const dictStore = useDictStore();
|
useDictStore();
|
||||||
// 获取所有字典类型
|
|
||||||
await dictStore.getDictTypes();
|
|
||||||
// const wsStore = useWsStore();
|
// const wsStore = useWsStore();
|
||||||
const userInfoData = await accountProfile();
|
const userInfoData = await accountProfile();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue