T
T
tigra2020-03-14 21:57:53
Docker
tigra, 2020-03-14 21:57:53

How to properly set up SWAGGER_JSON in docker?

I've been banging my head for several days and I don't understand why the documentation file in swagger is not being uploaded to the production environment.
docker-compose.yml

nginx:
    image: nginx:alpine
    volumes:
      - ${WORK_DIR}/server/nginx/${APP_ENV}/nginx.conf:/etc/nginx/nginx.conf
      - ${WORK_DIR}/server/nginx/${APP_ENV}/swagger.conf:/etc/nginx/conf.d/swagger.conf
    ports:
      - 80:80
    restart: always
    depends_on:
      - api
      - swagger-ui
    container_name: nginx
swagger-ui:
    image: swaggerapi/swagger-ui
    volumes:
      - ./swagger:/docs
    restart: always
    environment:
      SWAGGER_JSON: /docs/swagger.yml
    container_name: swagger-ui

nginx
server {
  listen 80;
  server_name doc.swagger.loc;

  location / {
    proxy_pass http://swagger-ui:8080/;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $http_host;
  }
}

and yes... on LAN everything works fine, the dock is substituted, the configs are exactly the same. I can not understand what could be the matter.
I noticed something interesting, on the local, when I look into the container:
docker exec -it swagger-ui ls
there is our daddy /docs and in it the file swagger.yml
docker exec -it swagger-ui ls /usr/share/nginx/html
and here too there is a swagger.yml file on the prod

:
docker exec -it swagger-ui ls
there is a /docs folder, BUT WTF, there are 2 files openapi.yaml openapi.yml, where they came from is not clear at all, it is impossible to open them
docker exec -it swagger- ui ls /usr/share/nginx/html
there is no swagger.yml ((the images are the same, docker-compose is identical, only the nginx server_name config is different

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2020-03-15
@tigroid3

probably all the same, there is no product on the host ./swaggerthat becomes in the containerdocs

volumes:
      - ./swagger:/docs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question