ค้นหาเว็บไซต์

typescript - Dockerfile: การคำนวณคีย์แคชล้มเหลว: "/tsconfig.json": ไม่พบ


ตอนนี้ฉันกำลังพยายามตั้งค่า GitHub actions เพื่อให้สร้างและส่ง backend ไปยัง DockerHub โดยอัตโนมัติ อย่างไรก็ตาม หาก workflow build-and-deploy-backend ถูกเรียกใช้งาน มันจะเริ่มสร้าง Docker Image แต่ล้มเหลวที่บรรทัด 23 ใน server/Dockerfile:

  22 |     COPY ./src ./src
  23 | >>> COPY ./tsconfig.json ./

ดู: https://github.com/bennodev19/dronies-watch/runs/4813916640?check_suite_focus=true

พร้อมกับข้อผิดพลาดนี้:

Dockerfile:23
--------------------
  21 |     # Move required app source into the working directory referenced with './'
  22 |     COPY ./src ./src
  23 | >>> COPY ./tsconfig.json ./
  24 |     
  25 |     # For debugging:
--------------------
error: failed to solve: failed to compute cache key: "/tsconfig.json": not found
Error: buildx failed with: error: failed to solve: failed to compute cache key: "/tsconfig.json": not found

ดู: https://github.com/bennodev19/dronies-watch/runs/4813916640?check_suite_focus=true

สามารถสร้างได้ในเครื่องโดยไม่มีปัญหา ทดสอบบน MacOS และ Windows 10

build-and-deploy-backend
*

jobs:
  build-and-deploy-backend:
    name: 🛠 Build Backend Image for Prod & Push to Dockerhub
    runs-on: ubuntu-latest
    steps:
      - name: 📚 Checkout
        uses: actions/checkout@v2

      - name: 🐳 Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

      - name: 🐳 Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: 🐳 Build and push Docker Image to DockerHub
         id: docker_build
         uses: docker/build-push-action@v2
         with:
          context: .
          file: server/Dockerfile # Path to the Dockerfile from which to build the Docker Image from (default {context}/Dockerfile)
          builder: ${{ steps.buildx.outputs.name }}
          push: true
          tags: latest

      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}

ดูไฟล์ทั้งหมด: https://github.com/bennodev19/dronies-watch/blob/master/.github/workflows/release.yaml

server/Dockerfile
FROM node:lts-alpine

RUN mkdir -p /app
WORKDIR /app

COPY package.json ./
COPY yarn.lock ./
RUN yarn install

COPY src ./src
COPY tsconfig.json ./

RUN yarn build

CMD [ "yarn", "start" ]

EXPOSE 5000

ดูไฟล์ทั้งหมดได้ที่: https://github.com/bennodev19/dronies-watch/blob/master/server/Dockerfile

อื่นๆ

  • URL ของที่เก็บ: https://github.com/bennodev19/dronies-watch