在前面已經創建了以下基礎設施:
接下來我們將用dockerfile 來 build 一個nginx images,並上傳到ECR中,在透過AWS ECS Fargate來去啟動。
mkdir conf web && touch Dockerfile ./conf/default.conf ./web/index.html
conf/
存放web伺服器(NGINX)配置檔
web/
存放應用程式的代碼目錄及檔案
Dockerfile
描述應用程式封裝所需要的相關環境
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
web/index.html
Code version is 1.0
Dockerfile
FROM nginx
WORKDIR /usr/share/nginx/html
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
COPY ./web/ /usr/share/nginx/html/
EXPOSE 80
docker build -t ithome-nginx .