首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在生产docker容器中构建和运行api-platform镜像?

如何在生产docker容器中构建和运行api-platform镜像?
EN

Stack Overflow用户
提问于 2019-01-08 18:19:57
回答 1查看 638关注 0票数 0

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

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

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

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

我正在努力理解如何从我的本地主机到服务器构建api-platform

EN

回答 1

Stack Overflow用户

发布于 2019-01-08 22:29:51

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

代码语言:javascript
复制
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: {}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54089679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档