LoginSignup
0
0

More than 5 years have passed since last update.

光の速さで静的ファイルしかおけないローカルサーバを立てる

Posted at

光の速さは盛りすぎだけど
まぁまぁ簡単

用途

適当なjsonを用意してcurlしたいとかjs試してみたいとか

環境

例によってローカルにインストールするのが嫌いなのでdocker使います
そしてhttp-serverを使います

手順

1.ファイル用意する

適当なディレクトリの中に
- Dockerfile
- docker-compose.yml
- public/index.html(public以下がドキュメントルートになるので)
を用意する

Dockerfile

Dockerfile
FROM node:8.11.3-alpine

WORKDIR /app

RUN apk update && \
    npm install -g npm http-server

docker-compose.yml

docker-compose.yml
version: '3'
services:
  app:
    build: .
    ports:
      - 9999:9999
    volumes:
      - .:/app
    stdin_open: true
    tty: true
    command: /bin/sh -c "http-server -a 0.0.0.0 -p 9999 --cors"

public/index.html

public/index.html
<html>ok baby</html>

3. 立ち上げる

$ docker-compose build
$ docker-compose up

4. ブラウザ開く

5. おしまい

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0