From b593556a9a9257064d020e899df1db4675bc8029 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Mon, 24 May 2021 01:12:47 +0800 Subject: [PATCH] Add Node.js workflow Closes #6 --- .github/workflows/build.yml | 22 +++++++++++++++++++++- Dockerfile | 10 ++++++---- Makefile | 6 +++--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 707f4ad..037e81a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Go +name: Node.js and Go on: push: @@ -13,6 +13,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: @@ -29,6 +34,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: @@ -45,6 +55,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: @@ -74,6 +89,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Set up Go 1.x uses: actions/setup-go@v2 with: diff --git a/Dockerfile b/Dockerfile index adadf3b..934e7f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,20 @@ FROM node:16-alpine3.13 as build-web -ARG NODE_ENV=production - WORKDIR /src COPY . . RUN cd web && npm install + +ARG NODE_ENV=production RUN cd web && npm run build FROM golang:1.16-alpine3.13 as build -ARG CGO_ENABLED=0 - +RUN apk add \ + make WORKDIR /src COPY --from=build-web . . + +ARG CGO_ENABLED=0 RUN make TAGS=production FROM scratch diff --git a/Makefile b/Makefile index 0422671..69aa3ad 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ NPM = npm .PHONY: all -all: web build +all: build .PHONY: clean clean: @@ -12,11 +12,11 @@ clean: .PHONY: build build: upl -upl: *.go web/*.tmpl +upl: *.go web/*.tmpl web $(GO) build -ldflags="-s -w" -tags "$(TAGS)" -v -o upl .PHONY: test -test: +test: web $(GO) test -cover -bench=. -v ./...