最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Nginx的Dockerfile

运维笔记admin14浏览0评论

Nginx的Dockerfile

Nginx的Dockerfile

我已经建立了一个React SPA。

在我的packer-main.json中,我具有以下配置:

{
    "variables": {
      "version": "{{ env `CI_PIPELINE_IID` }}"
    },
    "builders": [{
      "type": "docker",
      "image": "IMAGE NAME",
      "ecr_login": "true",
      "login_server": "LOGIN DETAILS",
      "commit": "true",
      "run_command": [ "-d", "-t", "-i", "{{.Image}}", "/bin/sh" ],
      "changes": [
        "EXPOSE 8080",
        "CMD [\"/usr/bin/openresty\"]"
    ]
    }],
    "provisioners": [
      {
        "type": "file",
        "only": ["docker"],
        "source": "build/",
        "destination": "/usr/local/openresty/nginx/html"
      },
      {
        "type": "shell",
        "inline": [
        "echo \"daemon off;\" >> /usr/local/openresty/nginx/conf/nginx.conf",
        "echo \"server { location / {# Set path root /var/www/; try_files $uri /index.html; } }  \" >> /usr/local/openresty/nginx/conf/nginx.conf"
        ]
      }
    ],
    "post-processors": [
      [
        {
          "type": "docker-tag",
          "repository": "my repo",
          "tag": "{{ user `version` }}"
        },
        {
          "type": "docker-push",
          "ecr_login": true,
          "login_server": "SERVER ADDRESS"
        }
      ]
    ]
}

我收到以下错误:

nginx: [emerg] "server" directive is not allowed here in /usr/local/openresty/nginx/conf/nginx.conf:118

我需要将我的应用程序重定向到当前未发生的index.html。

回答如下:

您需要在server中的http指令中放置nginx.conf

echo "http {server { location / {# Set path root /var/www/; try_files $uri /index.html; } }}"

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论