diff --git a/.dockerignore b/.dockerignore index 161765d..4dffa31 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -/dist /vendor /.idea /.github diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 09b52f2..7a2b9dd 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -74,6 +74,18 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + - name: "Populate frontend version information" + run: "cd webapp/frontend && ./git.version.sh" + - name: "Generate frontend" + uses: addnab/docker-run-action@v3 + with: + image: node:lts + options: -v ${{ github.workspace }}:/work + run: | + cd /work + make frontend + ls -alt /work + - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: @@ -101,8 +113,6 @@ jobs: type=ref,enable=true,event=branch,suffix=-web type=ref,enable=true,event=tag,suffix=-web images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: "Generate frontend version information" - run: "cd webapp/frontend && ./git.version.sh" # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image @@ -125,6 +135,18 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + - name: "Populate frontend version information" + run: "cd webapp/frontend && ./git.version.sh" + - name: "Generate frontend & version information" + uses: addnab/docker-run-action@v3 + with: + image: node:lts + options: -v ${{ github.workspace }}:/work + run: | + cd /work + make frontend + ls -alt /work + - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: @@ -150,8 +172,6 @@ jobs: type=ref,enable=true,event=branch,suffix=-omnibus type=ref,enable=true,event=tag,suffix=-omnibus images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: "Generate frontend version information" - run: "cd webapp/frontend && ./git.version.sh" # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image diff --git a/Makefile b/Makefile index a721ed7..1835f24 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ BINARY=\ linux/arm-7 \ linux/arm64 \ +.ONESHELL: # Applies to every targets in the file! .ONESHELL instructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains. .PHONY: all $(BINARY) all: $(BINARY) windows/amd64 @@ -50,5 +51,16 @@ docker-web: docker-omnibus: @echo "building omnibus docker image" docker build --build-arg TARGETARCH=amd64 -f docker/Dockerfile -t analogj/scrutiny-dev:omnibus . + +# reduce logging, disable angular-cli analytics for ci environment +frontend: export NPM_CONFIG_LOGLEVEL = warn +frontend: export NG_CLI_ANALYTICS = false +frontend: + cd webapp/frontend + npm install -g @angular/cli@9.1.4 + mkdir -p $(CURDIR)/dist + npm install + npm run build:prod -- --output-path=$(CURDIR)/dist + # clean: # rm scrutiny-collector-metrics-* scrutiny-web-* diff --git a/docker/Dockerfile b/docker/Dockerfile index 19fb17e..7411f23 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,21 +10,6 @@ RUN go mod vendor && \ go build -ldflags '-w -extldflags "-static"' -o scrutiny-collector-selftest collector/cmd/collector-selftest/collector-selftest.go && \ go build -ldflags '-w -extldflags "-static"' -o scrutiny-collector-metrics collector/cmd/collector-metrics/collector-metrics.go -######## -FROM node:lts-slim as frontendbuild - -#reduce logging, disable angular-cli analytics for ci environment -ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false - -WORKDIR /opt/scrutiny/src -COPY webapp/frontend /opt/scrutiny/src - -RUN npm install -g @angular/cli@9.1.4 && \ - mkdir -p /scrutiny/dist && \ - npm install && \ - npm run build:prod -- --output-path=/opt/scrutiny/dist - - ######## FROM ubuntu:latest as runtime ARG TARGETARCH @@ -52,7 +37,7 @@ COPY /rootfs/etc/cron.d/scrutiny /etc/cron.d/scrutiny COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/ COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /opt/scrutiny/bin/ COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/ -COPY --from=frontendbuild /opt/scrutiny/dist /opt/scrutiny/web +COPY dist /opt/scrutiny/web RUN chmod +x /opt/scrutiny/bin/scrutiny && \ chmod +x /opt/scrutiny/bin/scrutiny-collector-selftest && \ chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \ diff --git a/docker/Dockerfile.web b/docker/Dockerfile.web index 2ff577c..b424f52 100644 --- a/docker/Dockerfile.web +++ b/docker/Dockerfile.web @@ -8,21 +8,6 @@ COPY . /go/src/github.com/analogj/scrutiny RUN go mod vendor && \ go build -ldflags '-w -extldflags "-static"' -o scrutiny webapp/backend/cmd/scrutiny/scrutiny.go -######## -FROM node:lts-slim as frontendbuild - -#reduce logging, disable angular-cli analytics for ci environment -ENV NPM_CONFIG_LOGLEVEL=warn NG_CLI_ANALYTICS=false - -WORKDIR /opt/scrutiny/src -COPY webapp/frontend /opt/scrutiny/src - -RUN npm install -g @angular/cli@9.1.4 && \ - mkdir -p /opt/scrutiny/dist && \ - npm install && \ - npm run build:prod -- --output-path=/opt/scrutiny/dist - - ######## FROM ubuntu:latest as runtime EXPOSE 8080 @@ -32,7 +17,7 @@ ENV PATH="/opt/scrutiny/bin:${PATH}" RUN apt-get update && apt-get install -y ca-certificates curl tzdata && update-ca-certificates COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/ -COPY --from=frontendbuild /opt/scrutiny/dist /opt/scrutiny/web +COPY dist /opt/scrutiny/web RUN chmod +x /opt/scrutiny/bin/scrutiny && \ mkdir -p /opt/scrutiny/web && \ mkdir -p /opt/scrutiny/config && \