diff --git a/Dockerfile b/Dockerfile index 828a7b570..250cb3fc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,9 @@ RUN \ CGO_ENABLED=1 go test -race -p 1 -timeout="${BACKEND_TEST_TIMEOUT:-300s}" -covermode=atomic -coverprofile=/profile.cov_tmp ./... && \ cat /profile.cov_tmp | grep -v "_mock.go" > /profile.cov ; \ golangci-lint run --config ../.golangci.yml ./... ; \ - else echo "skip backend tests and linter" ; fi + else \ + echo "skip backend tests and linter" \ + ; fi RUN \ version="$(/script/version.sh)" && \ @@ -33,25 +35,41 @@ RUN \ FROM --platform=$BUILDPLATFORM node:16.13.2-alpine as build-frontend-deps ARG CI +ARG SKIP_FRONTEND_BUILD ENV HUSKY_SKIP_INSTALL=true -RUN apk add --no-cache --update git +RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \ + apk add --no-cache --update git \ + ; fi ADD frontend/package.json /srv/frontend/package.json ADD frontend/package-lock.json /srv/frontend/package-lock.json -RUN cd /srv/frontend && CI=true npm ci --loglevel warn +WORKDIR /srv/frontend +RUN mkdir node_modules +RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \ + CI=true npm ci --loglevel warn \ + else \ + echo "skip frontend build" \ + ; fi FROM --platform=$BUILDPLATFORM node:16.13.2-alpine as build-frontend ARG CI ARG SKIP_FRONTEND_TEST +ARG SKIP_FRONTEND_BUILD ARG NODE_ENV=production COPY --from=build-frontend-deps /srv/frontend/node_modules /srv/frontend/node_modules ADD frontend /srv/frontend -RUN cd /srv/frontend && \ - if [ -z "$SKIP_FRONTEND_TEST" ] ; then npm run lint test check; \ - else echo "skip frontend tests and lint" ; npm run build ; fi && \ - rm -rf ./node_modules +WORKDIR /srv/frontend +RUN mkdir public +RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \ + if [ -z "$SKIP_FRONTEND_TEST" ] ; then \ + npm run lint test check; \ + else \ + echo "skip frontend tests and lint" ; npm run build \ + ; fi \ + ; fi +RUN rm -rf ./node_modules FROM umputun/baseimage:app-v1.8.0 diff --git a/compose-dev-frontend.yml b/compose-dev-frontend.yml index e887e68e8..3d5d4ca87 100644 --- a/compose-dev-frontend.yml +++ b/compose-dev-frontend.yml @@ -13,6 +13,7 @@ services: dockerfile: Dockerfile args: - SKIP_BACKEND_TEST=true + - SKIP_FRONTEND_BUILD=true # - NODE_ENV=development image: umputun/remark42:dev diff --git a/site/src/docs/contributing/development/backend/index.md b/site/src/docs/contributing/development/backend/index.md index 9d053448d..b474f71be 100644 --- a/site/src/docs/contributing/development/backend/index.md +++ b/site/src/docs/contributing/development/backend/index.md @@ -11,10 +11,7 @@ cp compose-dev-backend.yml compose-private.yml # now, edit / debug `compose-private.yml` to your heart's content # build and run -make rundev -# this is an equivalent of these two commands: -# docker-compose -f compose-private.yml build -# docker-compose -f compose-private.yml up +docker-compose -f compose-private.yml up --build ``` It starts Remark42 on `127.0.0.1:8080` and adds local OAuth2 provider "Dev". To access the UI demo page go to . By default, you would be logged in as `dev_user`, defined as admin. You can tweak any of the [supported parameters](https://remark42.com/docs/configuration/parameters/) in corresponded yml file. diff --git a/site/src/docs/contributing/development/frontend/index.md b/site/src/docs/contributing/development/frontend/index.md index 9c3c259c0..014f04ccf 100644 --- a/site/src/docs/contributing/development/frontend/index.md +++ b/site/src/docs/contributing/development/frontend/index.md @@ -41,10 +41,7 @@ cp compose-dev-frontend.yml compose-private.yml # now, edit / debug `compose-private.yml` to your heart's content # build and run -make rundev -# this is an equivalent of these two commands: -# docker-compose -f compose-private.yml build -# docker-compose -f compose-private.yml up +docker-compose -f compose-private.yml up --build ``` Then in the new terminal tab or window, run the following to start the frontend with Hot Reloading: @@ -60,7 +57,7 @@ It starts Remark42 backend on `127.0.0.1:8080` and adds local OAuth2 provider "D Frontend Docker Compose config (`compose-dev-frontend.yml`) by default skips running backend related tests and sets `NODE_ENV=development` for frontend build. -**Important**: Before submitting your changes as a Pull Request, re-run the backend using the `make rundev` command and test your changes against , frontend, built statically (unlike frontend on port 9000, which runs dynamically). That is how Remark42 authors will test your changes once you submit them. +**Important**: Before submitting your changes as a Pull Request, run the backend using the `docker-compose -f compose-dev-frontend.yml build --build-arg SKIP_FRONTEND_BUILD=""; docker-compose -f compose-private.yml up` command and test your changes against , frontend, built statically (unlike frontend on port 9000, which runs dynamically). That is how Remark42 authors will test your changes once you submit them. #### Static build