docker-compose卷在文件夹中创建相同的文件夹名称

时间:2018-07-06 15:18:48

标签: docker docker-compose strapi

我的文件夹结构如下:

> api
 > Dockerfile
 > healthcheck.js
 > strapi.sh
> src
 > *****
> docker-compose.yml

当我运行docker-compose up时,它正在/api内创建文件夹名称./api

所以结构看起来像这样:

> api
 > api
 > Dockerfile
 > healthcheck.js
 > strapi.sh
> src
> docker-compose.yml

我需要./api/api根目录内的/api内容

这是我的docker-compose.yml文件内容:

version: '3'

services:
  web:
    image: node:9
    ports:
      - 3000:3000
    working_dir: /app
    volumes:
      - ./src:/app
    command: bash -c 'yarn && yarn dev'
    depends_on:
      - api
  api:
    image: strapi/strapi
    environment:
      - APP_NAME=api
      - DATABASE_CLIENT=mongo
      - DATABASE_HOST=db
      - DATABASE_PORT=27017
      - DATABASE_NAME=strapi
      - DATABASE_USERNAME=
      - DATABASE_PASSWORD=
      - HOST=localhost
    ports:
      - 1337:1337
    working_dir: /api
    volumes:
      - ./api:/api
    depends_on:
      - db
    restart: always
  db:
    image: mongo
    environment:
      - MONGO_INITDB_DATABASE=strapi
    ports:
      - 27017:27017
    volumes:
      - ./db:/data/db
    restart: always

我在/api中的Dockerfile:

FROM node:9.11.1-alpine

LABEL maintainer="Luca Perret <perret.luca@gmail.com>" \
      org.label-schema.vendor="Strapi" \
      org.label-schema.name="Strapi Docker image" \
      org.label-schema.description="Strapi containerized" \
      org.label-schema.url="https://strapi.io" \
      org.label-schema.vcs-url="https://github.com/strapi/strapi-docker" \
      org.label-schema.version=latest \
      org.label-schema.schema-version="1.0"



RUN npm install -g strapi@3.0.0-alpha.12.4


RUN chmod +x ./strapi.sh

EXPOSE 1337

COPY healthcheck.js ./
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
      CMD node /api/healthcheck.js

CMD ["./strapi.sh"]

strapi.sh

#!/bin/sh
set -ea

_stopStrapi() {
  echo "Stopping strapi"
  kill -SIGINT "$strapiPID"
  wait "$strapiPID"
}

trap _stopStrapi SIGTERM SIGINT


APP_NAME=${APP_NAME:-strapi-app}
DATABASE_CLIENT=${DATABASE_CLIENT:-mongo}
DATABASE_HOST=${DATABASE_HOST:-localhost}
DATABASE_PORT=${DATABASE_PORT:-27017}
DATABASE_NAME=${DATABASE_NAME:-strapi}

if [ ! -f "$APP_NAME/package.json" ]
then
    strapi new ${APP_NAME} --dbclient=$DATABASE_CLIENT --dbhost=$DATABASE_HOST --dbport=$DATABASE_PORT --dbname=$DATABASE_NAME --dbusername=$DATABASE_USERNAME --dbpassword=$DATABASE_PASSWORD
fi

cd $APP_NAME
strapi start &

strapiPID=$!
wait "$strapiPID"

我们将不胜感激。

0 个答案:

没有答案