Skip to main content

Triển khai code mới (C#)

1. Docker compose [dev]

version: '3.4'

services:
  nhaplieu.be.staging_new:
    image: nhaplieu.be.staging_new
    container_name: nhaplieu.be.staging_new_c
    build:
      context: ./nhaplieu.be
      dockerfile: ./src/nhaplieu.be.Web/Dockerfile
    restart: unless-stopped
    environment:
      - DOTNET_ENVIRONMENT=Staging
    ports:
      - 6001:8080

  nhaplieu.fe.staging_new:
    image: nhaplieu.fe.staging_new
    container_name: nhaplieu.fe.staging_new_c
    build:
      context: ./client
      dockerfile: Dockerfile
      args:
        - NODE_ENV=Staging
    restart: unless-stopped
    ports:
      - 6000:3000

2. K3s [dev]

# ---------------- Backend ----------------
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nhaplieu.be.staging.new
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nhaplieu.be.staging.new
  template:
    metadata:
      labels:
        app: nhaplieu.be.staging.new
    spec:
      hostNetwork: true
      containers:
        - name: nhaplieu-be-staging-new-c
          image: localhost:5000/nhaplieu.be.staging_new:latest
          ports:
            - containerPort: 8080
          env:
            - name: DOTNET_ENVIRONMENT
              value: "Staging"
---
apiVersion: v1
kind: Service
metadata: 
  name: nhaplieu-be-staging-new-service
spec:
  selector:
    app: nhaplieu.be.staging.new
  ports:
    - port: 6001
      targetPort: 8080
      nodePort: 30601
  type: NodePort

# ---------------- Frontend ----------------
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nhaplieu.fe.staging.new
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nhaplieu.fe.staging.new
  template:
    metadata:
      labels:
        app: nhaplieu.fe.staging.new
    spec:
      containers:
        - name: nhaplieu-fe-staging-new-c
          image: localhost:5000/nhaplieu.fe.staging_new:latest
          ports:
            - containerPort: 3000
          env:
            - name: NODE_ENV
              value: "Staging"
---
apiVersion: v1
kind: Service
metadata:
  name: nhaplieu-fe-staging-new-service
spec:
  selector:
    app: nhaplieu.fe.staging.new
  ports:
    - port: 6000
      targetPort: 3000
      nodePort: 30600
  type: NodePort