最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何在主机中没有 `node

网站源码admin36浏览0评论

如何在主机中没有 `node

如何在主机中没有 `node

具有以下预设:

version: "3.5"

services:

  FronServer:

    image: node:16-alpine
    container_name: Example-Production-FrontServer

    working_dir: /var/www/example

    volumes:
      - .:/var/www/example
      - FrontServerDependencies:/var/www/example/node_modules:nocopy

    command: sh -c "echo 'Installing dependencies ...' \
        && npm install --no-package-lock \
        && node FrontServerEntryPoint.js --environment production"

    ports: [ "8080:8080" ]
    environment:
      - DATABASE_HOST=Database

    depends_on: [ Database ]

  Database:

    image: postgres
    container_name: Example-Production-Database
    ports: [ "5432:5432" ]

    environment:
      - POSTGRES_PASSWORD=pass1234

    volumes:
      - DatabaseData:/data/example

volumes:
  FrontServerDependencies: { driver: "local" }
  DatabaseData: {}

启动docker-compose导致本地机器上的空node_modules目录:

如果没有额外的 Dockerfile,如何让它不出现在主机上?

就我而言,我需要安装的node_modules在容器停止后丢失。 也许 tmpfs 是我需要的,但还没有找到适合我的例子。

回答如下:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论