-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(frontend):Use a Monorepo architecture replace the current ar…
…chitecture of frontend project (#3545) * refactor(frontend):replace to monorepo * chore(frontend):add push auto image in makefile
- Loading branch information
1 parent
089f251
commit ed40683
Showing
73 changed files
with
13,028 additions
and
1,711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
**/Dockerfile | ||
**/.dockerignore | ||
**/node_modules/ | ||
**/npm-debug.log | ||
**/README.md | ||
**/.next/ | ||
**/.git/ | ||
**/.env.local | ||
**/config.yaml | ||
**/.vscode/ | ||
**/.yalc/ | ||
**/dist/ | ||
**/yalc.lock | ||
**/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright © 2022 sealos. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ARG name | ||
# ARG path | ||
FROM node:current-alpine AS runner | ||
WORKDIR /app | ||
ENV NODE_ENV production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
RUN sed -i 's/https/http/' /etc/apk/repositories | ||
RUN apk add curl \ | ||
&& apk add ca-certificates \ | ||
&& update-ca-certificates | ||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
# Install dependencies only when needed | ||
FROM node:current-alpine AS deps | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat && npm install -g pnpm | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager root workspace | ||
COPY pnpm-lock.yaml package.json pnpm-workspace.yaml ./ | ||
|
||
RUN \ | ||
[ -f pnpm-lock.yaml ] && pnpm fetch || \ | ||
(echo "Lockfile not found." && exit 1) | ||
COPY ./tsconfig.json ./tsconfig.json | ||
COPY ./tsconfig.deps.json ./tsconfig.deps.json | ||
COPY ./tsconfig.base.json ./tsconfig.base.json | ||
COPY ./packages ./packages | ||
|
||
RUN pnpm -r --offline --filter=./packages/* install \ | ||
&& pnpm -r --filter=./packages/* run build | ||
|
||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM node:current-alpine AS builder | ||
|
||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
# COPY --from=deps /app/packages ./packages | ||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN npm install -g pnpm | ||
|
||
|
||
COPY --from=deps /app/packages ./packages | ||
|
||
COPY . . | ||
# RUN pnpm -r --offline --filter=./packages/* install \ | ||
# && pnpm -r --filter=./packages/* run build | ||
|
||
|
||
ARG name | ||
ARG path | ||
|
||
RUN \ | ||
[ -f $path/pnpm-lock.yaml ] && (pnpm --offline --filter=$name install && pnpm --filter=$name run build) || \ | ||
(echo "Lockfile not found." && exit 1) | ||
|
||
# Production image, copy all the files and run next | ||
FROM runner | ||
|
||
ARG name | ||
ARG path | ||
# You only need to copy next.config.js if you are NOT using the default configuration | ||
# COPY --from=builder /app/desktop/next.config.js ./ | ||
COPY --from=builder /app/$path/public ./$path/public | ||
COPY --from=builder --chown=nextjs:nodejs /app/$path/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/$path/.next/static ./$path/.next/static | ||
|
||
ENV launchpath=./${path}/server.js | ||
|
||
ENTRYPOINT ["sh","-c","node ${launchpath}"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
ifeq ($(OS),Windows_NT) | ||
SHELL := powershell.exe | ||
DOCKER_USERNAME := $(DOCKER_USERNAME) | ||
else | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Linux) | ||
SHELL := /bin/bash | ||
CURRENT_USER := $(shell echo $$USER) | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
SHELL = /usr/bin/env bash | ||
CURRENT_USER := $(shell id -un) | ||
endif | ||
endif | ||
|
||
ifneq ($(strip $(DOCKER_USERNAME)),) | ||
imageOwner := $(DOCKER_USERNAME)/ | ||
else | ||
imageOwner := | ||
endif | ||
|
||
# build image | ||
buildTargets := \ | ||
desktop \ | ||
providers/terminal \ | ||
providers/adminer \ | ||
providers/bytebase \ | ||
providers/costcenter \ | ||
providers/dbprovider \ | ||
providers/applaunchpad \ | ||
providers/imagehub | ||
|
||
buildTargets-all := $(addprefix image-build-,$(buildTargets)) | ||
pushTargets-all := $(addprefix image-push-,$(buildTargets)) | ||
$(foreach target,$(buildTargets),$(eval .PHONY: image-build-$($(target)))) | ||
$(foreach target,$(buildTargets),$(eval .PHONY: image-push-$($(target)))) | ||
$(foreach target,$(buildTargets),$(eval .PHONY: dev-$($(target)))) | ||
$(foreach target,$(buildTargets),$(eval .PHONY: build-$($(target)))) | ||
.PHONY: all dev-desktop image-prebuild | ||
|
||
all: image-prebuild $(buildTargets-all) | ||
|
||
push-images: image-prebuild $(pushTargets-all) | ||
fetch-deps: pnpm-lock.yaml | ||
pnpm fetch | ||
build-packages: fetch-deps | ||
pnpm -r --offline --filter=./packages/* install | ||
pnpm -r --offline --filter=./packages/* build | ||
build-providers/%: build-packages | ||
pnpm -r --offline --filter=./providers/$* install | ||
pnpm -r --offline --filter=./providers/$* build | ||
build-%: build-packages | ||
pnpm -r --offline --filter=$* install | ||
pnpm -r --offline --filter=$* build | ||
dev-providers/%: build-packages | ||
pnpm -r --offline --filter=./providers/$* install | ||
pnpm -r --offline --filter=./providers/$* dev | ||
dev-%: build-packages | ||
pnpm -r --offline --filter=$* install | ||
pnpm -r --offline --filter=$* dev | ||
|
||
# prebuild-image-for -j | ||
image-prebuild: pnpm-lock.yaml | ||
docker build --target deps . -t $(imageOwner)sealos-deps:dev | ||
|
||
image-build-providers/%: image-prebuild | ||
docker build -t $(imageOwner)sealos-$*:dev --build-arg path=providers/$* --build-arg name=$* . | ||
image-build-%: image-prebuild | ||
docker build -t $(imageOwner)sealos-$*:dev --build-arg path=$* --build-arg name=$* . | ||
|
||
image-push-providers/%: image-build-providers/% | ||
docker push $(imageOwner)sealos-$*:dev | ||
image-push-%: image-build-% | ||
docker push $(imageOwner)sealos-$*:dev | ||
# Default target to run all builds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.