docker - 如何构建 api-platform 镜像并将其运行到生产 docker 容器?

标签 docker ubuntu api-platform.com

我遵循了 api-platform 教程,并在我的 localhost 上使用 Docker 成功构建并启动了应用程序。机器。

我有一个运行 Ubuntu 16.04.5 LTS 的生产服务器,以及一个新安装的 Docker 版本 18.06.1-ce。

我将如何在本地机器上构建此代码并在 Docker 服务器上运行它?

我也看过 Deploying API Platform Applications documentation但我不确定如何使用它。

我正在努力了解如何从我的本地主机构建 api 平台到服务器

最佳答案

这是 docker-compose.yml 文件 请试试这个 docker-compose up -d

version: '3.4'
services:
  php:
    image: ${CONTAINER_REGISTRY_BASE}/php
    build:
      context: ./api
      target: api_platform_php
      cache_from:
        - ${CONTAINER_REGISTRY_BASE}/php
        - ${CONTAINER_REGISTRY_BASE}/nginx
        - ${CONTAINER_REGISTRY_BASE}/varnish
    depends_on:
      - db
    # Comment out these volumes in production
    volumes:
      - ./api:/srv/api:rw,cached
      # If you develop on Linux, uncomment the following line to use a bind-mounted host directory instead
      # - ./api/var:/srv/api/var:rw

  api:
    image: ${CONTAINER_REGISTRY_BASE}/nginx
    build:
      context: ./api
      target: api_platform_nginx
      cache_from:
        - ${CONTAINER_REGISTRY_BASE}/php
        - ${CONTAINER_REGISTRY_BASE}/nginx
        - ${CONTAINER_REGISTRY_BASE}/varnish
    depends_on:
      - php
    # Comment out this volume in production
    volumes:
      - ./api/public:/srv/api/public:ro
    ports:
      - "8080:80"

  cache-proxy:
    image: ${CONTAINER_REGISTRY_BASE}/varnish
    build:
      context: ./api
      target: api_platform_varnish
      cache_from:
        - ${CONTAINER_REGISTRY_BASE}/php
        - ${CONTAINER_REGISTRY_BASE}/nginx
        - ${CONTAINER_REGISTRY_BASE}/varnish
    depends_on:
      - api
    volumes:
      - ./api/docker/varnish/conf:/usr/local/etc/varnish:ro
    tmpfs:
      - /usr/local/var/varnish:exec
    ports:
      - "8081:80"

  db:
    # In production, you may want to use a managed database service
    image: postgres:10-alpine
    environment:
      - POSTGRES_DB=api
      - POSTGRES_USER=api-platform
      # You should definitely change the password in production
      - POSTGRES_PASSWORD=!ChangeMe!
    volumes:
      - db-data:/var/lib/postgresql/data:rw
      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/db/data:/var/lib/postgresql/data:rw
    ports:
      - "5432:5432"

  client:
    # Use a static website hosting service in production
    # See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
    image: ${CONTAINER_REGISTRY_BASE}/client
    build:
      context: ./client
      cache_from:
        - ${CONTAINER_REGISTRY_BASE}/client
    env_file:
      - ./client/.env
    volumes:
      - ./client:/usr/src/client:rw,cached
      - /usr/src/client/node_modules
    ports:
      - "80:3000"

  admin:
    # Use a static website hosting service in production
    # See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
    image: ${CONTAINER_REGISTRY_BASE}/admin
    build:
      context: ./admin
      cache_from:
        - ${CONTAINER_REGISTRY_BASE}/admin
    volumes:
      - ./admin:/usr/src/admin:rw,cached
      - /usr/src/admin/node_modules
    ports:
      - "81:3000"

  h2-proxy:
    # Don't use this proxy in prod
    build:
      context: ./h2-proxy
    depends_on:
      - client
      - admin
      - api
      - cache-proxy
    ports:
      - "443:443"
      - "444:444"
      - "8443:8443"
      - "8444:8444"

volumes:
  db-data: {}

关于docker - 如何构建 api-platform 镜像并将其运行到生产 docker 容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54089679/

相关文章:

docker - docker daemon 在部署 compose 环境时用完要分配的网络 IP 地址时会发生什么?

python - 使用 docker 镜像运行 python 脚本

ruby - 如何在Docker Ruby-2.5.1 Alpine Linux上安装wkhtmltopdf?

docker - 如何在子文件夹中使用 go.mod 构建 golang docker 镜像?

java - Flume的一些问题

php - 装饰服务的循环引用问题

linux - 在 CentOS 6.4 上构建 gvim 7.4

ubuntu - 如何配置 Jenkins 运行在 80 端口

php - Api 平台处理文件上传

php - 获取在现有 Symfony 3.4 应用程序中运行的 API 平台文档