gpt4 book ai didi

docker - 将docker容器部署到heroku会产生:与特权相关的Nginx错误

转载 作者:行者123 更新时间:2023-12-02 18:34:38 37 4
gpt4 key购买 nike

如标题所述,将应用程序部署到Heroku并观察日志后出现的错误:

nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2

我的Dockerfile是:
#build stage
FROM node:14-alpine AS build
WORKDIR /usr/src/ssat-prep/client
ENV PATH /app/node_modules/.bin:$PATH
COPY . .
RUN yarn install --production && yarn build

#run and serve stage
FROM nginx:alpine
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /usr/src/ssat-prep/client/build /usr/share/nginx/html
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]

我的nginx.conf:
server {

listen 3000;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}

}

请帮助我部署此应用

最佳答案

Heroku在环境变量PORT中为此提供了一个端口,而在Dockerfile中公开则不起作用。

#build stage
FROM node:14-alpine AS build
WORKDIR /usr/src/ssat-prep/client
ENV PATH /app/node_modules/.bin:$PATH
COPY . .
RUN yarn install --production && yarn build

#run and serve stage
FROM nginx:alpine
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /usr/src/ssat-prep/client/build /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]
server {

listen $PORT;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}

}

关于docker - 将docker容器部署到heroku会产生:与特权相关的Nginx错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61788582/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com