提交 b6fbb1f8 作者: 余乾开

feat(Dockerfile):Dockerfile

上级 49787d8b
.DS_Store
.next
node_modules
Dockerfile
.dist
\ No newline at end of file
name: Build and Push to ACR
on:
push:
### Production
branches: ["release/chuck"]
env:
REGION_ID: cn-shenzhen
REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
NAMESPACE: sharefly
IMAGE: web
TAG: ${{ github.sha }}
ACR_EE_REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
ACR_EE_INSTANCE_ID: cri-yhk5zgfc2v1sia6l
ACR_EE_NAMESPACE: sharefly
ACR_EE_IMAGE: web
ACR_EE_TAG: ${{ github.sha }}
JAVA_VERSION: "8"
GITLAB_URL: https://oauth2:MjVJKxB7m4tCy7symBzn@git.mmcuav.cn/iuav/csf-web.git
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
### Production
environment: prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to ACR EE with the AccessKey pair
uses: aliyun/acr-login@v1
with:
login-server: "https://${{ env.ACR_EE_REGISTRY }}"
region-id: "${{ env.REGION_ID }}"
username: "QD--KeBiTeHangKong@1354706964800968"
password: "MMC@2023&ACR"
instance-id: "${{ env.ACR_EE_INSTANCE_ID }}"
- name: Build and push image to ACR EE
run: |
docker build -t "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG" .
docker push "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG"
### Production
- name: Kustomize Set Image
run: |-
cd kustomization/overlays/prod
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash /dev/stdin 3.8.6
./kustomize edit set image REGISTRY/NAMESPACE/IMAGE:TAG=$REGISTRY/$NAMESPACE/$IMAGE:$TAG
### Production
- name: Commit and Push
run: |
git config user.name "Chuck"
git config user.email "Chuck@users.noreply.github.com"
git remote set-url origin "$GITLAB_URL"
git commit -am "generated Image update"
git push origin master
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base 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
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# 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 yarn build
# If using npm comment out above and use below instead
# RUN npm run build
# Production image, copy all the files and run next
FROM base 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
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: web-map
namespace: default
data:
SPRING_PROFILES_ACTIVE: default
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deployment
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: REGISTRY/NAMESPACE/IMAGE:TAG
resources:
limits:
memory: 512Mi
cpu: 100m
ports:
- containerPort: 3000
\ No newline at end of file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
app: web
resources:
- ./deployment.yaml
- ./service.yaml
- ./configMap.yaml
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: web-svc
namespace: default
spec:
selector:
app: web
type: NodePort
ports:
- protocol: TCP
port: 3000
apiVersion: v1
kind: ConfigMap
metadata:
name: web-map
data:
SPRING_PROFILES_ACTIVE: dev
\ No newline at end of file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
#namePrefix: dev-
namespace: dev
commonLabels:
variant: dev
commonAnnotations:
note: This is dev!
patches:
- path: ./configMap.yaml
- path: ./service-patch.yaml
target:
kind: Service
name: web-svc
- op: replace
path: /spec/ports/0/nodePort
value: 31001
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: web-map
data:
SPRING_PROFILES_ACTIVE: prod
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-deployment
spec:
replicas: 1
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: prod
#namePrefix: prod-
commonLabels:
variant: prod
commonAnnotations:
note: This is prod!
patches:
- path: increase_replicas.yaml
- path: configMap.yaml
- path: service-patch.yaml
target:
kind: Service
name: web-svc
- op: replace
path: /spec/ports/0/nodePort
value: 31000
\ No newline at end of file
......@@ -10,6 +10,7 @@ const nextConfig = {
distDir,
reactStrictMode: true,
transpilePackages: ["antd"],
output: "standalone",
compiler: {
styledComponents: true,
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论