小编vig*_*esh的帖子

docker-compose 文件中的命令键是如何工作的

我正在尝试了解 docker 示例应用程序“example-voting-app”。我正在尝试使用 docker-compose 构建应用程序。我对 docker compose 文件中的“command”键的行为和 Dockerfile 中的 CMD 指令感到困惑。该应用程序包含一项名为“投票”的服务。docker-compose.yml 文件中投票服务的配置为:

services: # we list all our application services under this 'services' section.
  vote:  
    build: ./vote # specifies docker to build the 
    command: python app.py
    volumes:
     - ./vote:/app
    ports:
      - "5000:80"
    networks:
      - front-tier
      - back-tier
Run Code Online (Sandbox Code Playgroud)

./vote 目录下提供的 Dockerfile 配置如下:

# Using official python runtime base image
FROM python:2.7-alpine

# Set the application directory
WORKDIR /app

# Install our requirements.txt
ADD requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt …
Run Code Online (Sandbox Code Playgroud)

docker docker-compose

3
推荐指数
1
解决办法
558
查看次数

如何在 gorilla mux 的 Get Subrouter 中为特定路由使用特定中间件

我对 Gorilla mux 路由有一个特定要求,我想为一个子路由器下的不同路由添加不同的中间件(在我的例子中是 GET 子路由器)。下面是我的路由代码:

    // create a serve mux
    sm := mux.NewRouter()

    // register handlers
    postR := sm.Methods(http.MethodPost).Subrouter()
    postR.HandleFunc("/signup", uh.Signup)
    postR.HandleFunc("/login", uh.Login)
    postR.Use(uh.MiddlewareValidateUser)

    getR := sm.Methods(http.MethodGet).Subrouter()
    getR.HandleFunc("/refresh-token", uh.RefreshToken)
    getR.HandleFunc("/user-profile", uh.GetUserProfile)
Run Code Online (Sandbox Code Playgroud)

在上面的路由器逻辑中,我的 /refresh-token 和 /user-profile 令牌都在 getR 路由器下。我还有两个中间件函数,称为 ValidateAccessToken 和 ValidateRefreshToken。我想将 ValidateRefreshToken 中间件函数用于“/refresh-token”路由,并将 ValidateAccessToken 用于 GET 子路由器下的所有其他路由。我想用 Gorilla mux 路由本身来做到这一点。请建议我完成上述场景的适当方法。感谢您的时间和精力。

routes go gorilla

2
推荐指数
2
解决办法
2384
查看次数

标签 统计

docker ×1

docker-compose ×1

go ×1

gorilla ×1

routes ×1