目前架構是兩個前端 (網站前台及後台) 與一個後端
使用drone進行自動包版及上傳至dockerhub
接著在VM上使用docker-compose啟用服務
沒使用k8s是因為服務不大,若是真起了一個Cluster 可能就比原本的服務吃資源了
yaml檔如下
version: "3.3"
services:
  nginx:
    image: nginx:stable
    restart: always
    volumes:
      - ./conf.d:/etc/nginx/conf.d
    ports:
      - "8082:8080"
    networks:
      - internal_network
  server:
    image: dockerhub/server:0.0.6
    restart: always
    networks:
      - internal_network
  web:
    image: dockerhub/web:0.0.3
    restart: always
    networks:
      - internal_network
  man:
    image: dockerhub/webman:0.0.4
    restart: always
    networks:
      - internal_network
networks:
  internal_network:
    driver: bridge
內部的三個服務統一由一個nginx對外,再經由proxy進到各個服務去
nginx conf如下
server {
  listen 8080;
  index index.html;
  location ~ /api {
      proxy_pass http://server:7000;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
  }
  location /admin/ {
      proxy_pass http://webman:8080/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
  }
  location / {
      proxy_pass http://web:8080;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
  } 
}
目前服務都正常運作,只是在設定上有些疑問想請教
以下是drone的設定檔
kind: pipeline
type: docker
name: test
steps
  - name: tsc
    when:
      event: tag
    pull: if-not-exists
    image: node:current-alpine3.12
    commands:
      - yarn global add typescript
      - yarn install
      - tsc
  - name: build-image
    when:
      event: tag
    pull: if-not-exists
    image: plugins/docker
    settings:
      registry: registry.hub.docker.com
      repo: registry.hub.docker.com/dockerhub/web 
      dockerfile: dockerfile 
      auto_tag: true 
      username:
        from_secret: hubname
      password:
        from_secret: hubsecret
會根據git的tag決定image的tag
如果將每次上傳的新image都設定成latest,那是不是需要去修改舊版本的image tag
還是有比較好的方式嗎?