【发布时间】:2020-09-30 02:00:34
【问题描述】:
我一直在尝试使用 nginx 作为服务器构建 docker 容器,该容器在本地运行良好,但由于某种原因,我无法将其部署到 Google 的 App 引擎。您能否首先让我知道这是否可能?如果可能的话,请您也指导我。我在 GCP 的容器存储库中也有该图像,但找不到将其部署到 GAE 的方法
这是我的码头工人
#STEP1
# we name it as builder so as to use in the following instructions
further
FROM node:8.12.0-alpine as builder
#Now install angular cli globally
RUN npm install -g @angular/cli@6.2.1
#Install git and openssh because alpine image doenst have git and all
modules in npm has the dependicies which are all uploaded in git
#so to use them we need to be able git
RUN apk add --update git openssh
#create a new direcotry for the prj and change its directory to it
RUN mkdir ./adtech-prj
#copy the package json #dont copy package.lock json now
COPY package.json package-lock.json ./adtech-prj/
#this is required to place all our files inside this directory
WORKDIR ./adtech-prj
#this copies all files to the working directory
COPY . .
# --RUN pwd && ls
RUN npm cache clear --force && npm i
RUN $(npm bin)/ng build --prod --aot
### STAGE 2: Setup ###
FROM nginx:1.15-alpine
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
## Copy our default nginx config
COPY nginx.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
RUN pwd && ls
COPY --from=builder /adtech-prj/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
这是我的 nginx 配置 - 一个简单的
server {
listen 80 default_server;
#server_name *.adtechportal.com;
sendfile on;
default_type application/octet-stream;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
#proxy_pass: "http://localhost:8080/AdTechUIContent"
#uncomment to include naxsi rules
#include /etc/nginx/naxsi.rules
}
}
【问题讨论】:
标签: angular docker google-app-engine nginx dockerfile