From a37a38c5367e480f6c27f0a8d7a415f5ed3ae99d Mon Sep 17 00:00:00 2001 From: bndw Date: Mon, 8 Jun 2020 20:33:12 -0700 Subject: :construction_worker: CI: Multi-stage build --- Dockerfile | 11 ++++++++++- Makefile | 4 +--- README.md | 10 ++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15ee3a9..5a5f92f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,11 @@ +FROM mhart/alpine-node:14 as builder + +WORKDIR /tmp +COPY . . + +RUN yarn && yarn build + +### +# production image FROM nginx:stable-alpine -COPY build /usr/share/nginx/html +COPY --from=builder /tmp/build /usr/share/nginx/html diff --git a/Makefile b/Makefile index 6386336..421bb16 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,6 @@ all: dev .PHONY: build build: - yarn - yarn build docker build -t $(TAG_LATEST) . .PHONY: dev @@ -17,7 +15,7 @@ dev: yarn start .PHONY: run -run: build +run: docker run --rm -p 8080:80 $(TAG_LATEST) .PHONY: publish diff --git a/README.md b/README.md index 704442c..1e205dc 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,16 @@ It looks like this: Run the latest Docker image on http://localhost:8080 ``` -docker run --rm -p 8080:80 bndw/wifi-card:latest +make run ``` -Or run the live-reload server on http://localhost:8080 +Build the Docker image + +``` +make build +``` + +Run the live-reload server on http://localhost:8080 ``` make dev -- cgit v1.2.3