Code Monkey home page Code Monkey logo

simple-deploy's Introduction

使用 Docker 部署前端之简单版

本仓库为前端部署专栏配套代码。

本地版

使用 serve 在本地起一个静态服务器

$ npx serve .

或者,使用 node.js 直接写一个服务,在本地起一个静态服务器

$ node server-fs.js

琐碎版: docker cli

使用 docker 命令行工具去构建及运行容器

# 构建一个名为 simple-app 的镜像
$ docker build -f node.Dockerfile -t simple-node-app .

# 根据该镜像运行容器
$ docker run -d --rm -p 3000:3000 simple-node-app

nginx版: docker cli

使用 docker 命令行工具去构建及运行容器

# 构建一个名为 simple-app 的镜像
$ docker build -f nginx.Dockerfile -t simple-nginx-app .

# 根据该镜像运行容器
$ docker run -d --rm -p 3000:80 simple-nginx-app

高效版: docker-compose

使用 docker-compose 运行容器,同时部署 node 版与 nginx 版

$ docker-compose up --build

Nginx 学习版

通过该配置文件可以在容器中学习 nginx,不再受限于宿主环境。学习 nginx 请先进入 learn-nginx 目录。

API 文档置于 learn nginx by docker,可使用 Apifox 直接打开。

可通过以下步骤,在 apifox 中调试 nginx 接口。

  1. 下载 Apifox
  2. 在 Apifox 中克隆该项目
  3. 在 Github 中克隆示例仓库
  4. 克隆下来后,进入 learn-nginx 目录
  5. docker-compose up 启动容器
  6. 打开 Apifox 调试接口学习 nginx

location

$ docker-compose up location

$ docker-compose up location2 api

proxy

$ docker-compose up proxy

simple-deploy's People

Contributors

shfshanyue avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.