Skip to content

Commit

Permalink
workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
akellbl4 committed Jul 19, 2022
1 parent 9c1a827 commit 8dee468
Show file tree
Hide file tree
Showing 372 changed files with 877 additions and 915 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/target/
/var/
/frontend/node_modules/
/frontend/public/
/frontend/apps/remark42/node_modules/
/frontend/apps/remark42/public/
/.vscode/
/.idea/
/bin/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-frontend-size-limit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
paths:
- ".github/workflows/ci-frontend-size-limit.yml"
- "frontend/**"
- "frontend/apps/remark42/**"
- "!**.md"

jobs:
Expand All @@ -27,4 +27,4 @@ jobs:
uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: frontend
directory: ./frontend/apps/remark42
20 changes: 10 additions & 10 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
tags:
paths:
- ".github/workflows/ci-frontend.yml"
- "frontend/**"
- "frontend/apps/remark42/**"
- "!**.md"
pull_request:
paths:
- ".github/workflows/ci-frontend.yml"
- "frontend/**"
- "frontend/apps/remark42/**"
- "!**.md"

jobs:
Expand Down Expand Up @@ -55,8 +55,8 @@ jobs:
working-directory: ./frontend

- name: Run translations check
run: pnpm run check:translation
working-directory: ./frontend
run: pnpm translation-check
working-directory: ./frontend/apps/remark42

check-typescript:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -98,8 +98,8 @@ jobs:
working-directory: ./frontend

- name: Run type check
run: pnpm run check:types
working-directory: ./frontend
run: pnpm type-check
working-directory: ./frontend/apps/remark42

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -141,8 +141,8 @@ jobs:
working-directory: ./frontend

- name: Run linters
run: pnpm run lint
working-directory: ./frontend
run: pnpm lint
working-directory: ./frontend/apps/remark42

test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -185,9 +185,9 @@ jobs:

- name: Collect tests coverage
run: pnpm run test --coverage
working-directory: ./frontend
working-directory: ./frontend/apps/remark42

- name: Submit coverage
run: ${{ github.workspace }}/frontend/node_modules/.bin/codecov
run: ${{ github.workspace }}/frontend/apps/remark42/node_modules/.bin/codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
101 changes: 49 additions & 52 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
FROM --platform=$BUILDPLATFORM node:16.15.1-alpine AS frontend-deps

ARG SKIP_FRONTEND_TEST
ARG SKIP_FRONTEND_BUILD

WORKDIR /srv/frontend/

COPY ./frontend/package.json ./frontend/pnpm-lock.yaml ./frontend/pnpm-workspace.yaml /srv/frontend/
COPY ./frontend/apps/remark42/package.json /srv/frontend/apps/remark42/

RUN \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
apk add --no-cache --update git && \
npm i -g pnpm; \
fi

RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
pnpm i; \
fi


FROM --platform=$BUILDPLATFORM frontend-deps AS build-frontend

ARG SKIP_FRONTEND_TEST
ARG SKIP_FRONTEND_BUILD
ENV CI=true

WORKDIR /srv/frontend/apps/remark42/

COPY ./frontend/apps/remark42/ /srv/frontend/apps/remark42/

RUN \
if [ -z "$SKIP_FRONTEND_TEST" ]; then \
pnpm lint type-check translation-check test; \
else \
echo 'Skip frontend test'; \
fi

RUN \
if [ -z "$SKIP_FRONTEND_BUILD" ]; then \
pnpm build; \
else \
mkdir /srv/frontend/apps/remark42/public; \
echo 'Skip frontend build'; \
fi

FROM umputun/baseimage:buildgo-v1.9.1 as build-backend

ARG CI
Expand Down Expand Up @@ -25,64 +72,14 @@ RUN \
cat /profile.cov_tmp | grep -v "_mock.go" > /profile.cov ; \
golangci-lint run --config ../.golangci.yml ./... ; \
else \
echo "skip backend tests and linter" \
echo "skip backend tests and linter" \
; fi

RUN \
version="$(/script/version.sh)" && \
echo "version=$version" && \
go build -o remark42 -ldflags "-X main.revision=${version} -s -w" ./app

FROM --platform=$BUILDPLATFORM node:16.15.1-alpine as build-frontend-deps

ARG CI
ARG SKIP_FRONTEND_BUILD
ENV HUSKY_SKIP_INSTALL=true

WORKDIR /srv/frontend
COPY frontend/package.json frontend/pnpm-lock.yaml /srv/frontend/
RUN \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
apk add --no-cache --update git && \
npm i -g pnpm; \
fi

RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
pnpm i; \
fi

FROM --platform=$BUILDPLATFORM node:16.15.1-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
COPY ./frontend /srv/frontend
WORKDIR /srv/frontend
RUN \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
apk add --no-cache --update git && \
npm i -g pnpm; \
fi

RUN \
if [ -z "$SKIP_FRONTEND_TEST" ]; then \
echo 'Skip frontend test'; \
else \
pnpm lint test check; \
fi

RUN \
if [ -z "$SKIP_FRONTEND_BUILD" ]; then \
mkdir public; \
echo 'Skip frontend build'; \
else \
pnpm build; \
fi

FROM umputun/baseimage:app-v1.9.1

WORKDIR /srv
Expand All @@ -95,7 +92,7 @@ RUN chmod +x /entrypoint.sh /usr/local/bin/backup /usr/local/bin/restore /usr/lo

COPY --from=build-backend /build/backend/remark42 /srv/remark42
COPY --from=build-backend /build/backend/templates /srv
COPY --from=build-frontend /srv/frontend/public/ /srv/web
COPY --from=build-frontend /srv/frontend/apps/remark42/public/ /srv/web/
COPY docker-init.sh /srv/init.sh
RUN chown -R app:app /srv
RUN ln -s /srv/remark42 /usr/bin/remark42
Expand Down
39 changes: 16 additions & 23 deletions Dockerfile.artifacts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
FROM node:16.15.1-alpine as build-frontend-deps
FROM node:16.15.1-alpine AS frontend-deps

ARG CI

ENV SKIP_FRONTEND_TEST=true
ENV CI=true

ADD frontend/package.json /srv/frontend/package.json
ADD frontend/pnpm-lock.yaml /srv/frontend/pnpm-lock.yaml
RUN
cd /srv/frontend && \
apk add --no-cache --update git && \
npm i -g pnpm && \
pnpm i
WORKDIR /srv/frontend

COPY ./frontend/package.json ./frontend/pnpm-lock.yaml ./frontend/pnpm-workspace.yaml /srv/frontend
COPY ./frontend/apps/remark42/package.json /srv/frontend/apps/remark42/package.json

FROM node:16.15.1-alpine as build-frontend
RUN apk add --no-cache --update git && npm i -g pnpm
RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 pnpm i

ARG CI
ARG NODE_ENV=production
ENV SKIP_FRONTEND_TEST=true
ENV HUSKY_SKIP_INSTALL=true
FROM frontend-deps AS build-frontend

ENV NODE_ENV=production
ENV CI=true

COPY --from=build-frontend-deps /srv/frontend/node_modules /srv/frontend/node_modules
ADD frontend /srv/frontend
RUN cd /srv/frontend && \
npm run build && \
rm -rf ./node_modules
WORKDIR /srv/frontend/apps/remark42/
COPY ./frontend/apps/remark42/ /srv/frontend/apps/remark42/
RUN pnpm build

FROM umputun/baseimage:buildgo-v1.9.1 as build-backend

Expand All @@ -38,7 +31,7 @@ ADD backend /build/backend
ADD README.md /build/
ADD LICENSE /build/

COPY --from=build-frontend /srv/frontend/public/ web
COPY --from=build-frontend /srv/frontend/apps/remark42/public/ /build/backend/web/

RUN \
export WEB_ROOT=/build/backend/web && \
Expand All @@ -50,7 +43,7 @@ RUN \
ls -la /build/backend/web/

RUN \
version=$("/script/version.sh") && echo "version=${version}" && \
version=$("/script/version.sh") && echo "version=${version}" && \
export GOFLAGS="-mod=vendor" && \
GOOS=linux GOARCH=amd64 go build -o remark42.linux-amd64 -ldflags "-X main.revision=${version} -s -w" ./app && \
GOOS=linux GOARCH=386 go build -o remark42.linux-386 -ldflags "-X main.revision=${version} -s -w" ./app && \
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dockerx:

release:
docker build -f Dockerfile.artifacts --no-cache --pull --build-arg CI=true \
--build-arg GITHUB_REF=$(GITHUB_REF) --build-arg GITHUB_SHA=$(GITHUB_SHA) -t remark42.bin .
--build-arg GITHUB_REF=$(GITHUB_REF) --build-arg GITHUB_SHA=$(GITHUB_SHA) -t remark42.bin .
- @docker rm -f remark42.bin 2>/dev/null || exit 0
- @mkdir -p bin
docker run -d --name=remark42.bin remark42.bin
Expand All @@ -47,7 +47,7 @@ frontend:
rundev:
docker pull umputun/baseimage:buildgo-v1.9.1
SKIP_BACKEND_TEST=true SKIP_FRONTEND_TEST=true GITHUB_REF=$(GITHUB_REF) GITHUB_SHA=$(GITHUB_SHA) CI=true \
docker-compose -f compose-private.yml build
docker-compose -f compose-private.yml build
docker-compose -f compose-private.yml up

.PHONY: bin backend
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ public
.env
tsconfig.tsbuildinfo
coverage
!remark42
2 changes: 2 additions & 0 deletions frontend/.husky/post-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# .husky/post-commit

cd frontend
git update-index --again
5 changes: 3 additions & 2 deletions frontend/.husky/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# .husky/pre-commit
npx --no-install lint-staged
lint-staged

cd frontend
pnpm lint-staged
15 changes: 12 additions & 3 deletions frontend/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
module.exports = {
'./**/*.{ts,tsx,js,jsx}': ['eslint --fix --max-warnings=0', 'prettier --write'],
'./**/*.css': ['prettier --write', 'stylelint'],
'./templates/**.html': ['prettier --write', 'stylelint'],
"./**/*.{ts,tsx,js,jsx}": [
"cd apps/remark42 && pnpm lint-staged:lint:scripts",
"cd apps/remark42 && pnpm lint-staged:format",
],
"./**/*.css": [
"cd apps/remark42 && pnpm lint-staged:lint:styles",
"cd apps/remark42 && pnpm lint-staged:format",
],
"./templates/**.html": [
"cd apps/remark42 && pnpm lint-staged:lint:styles",
"cd apps/remark42 && pnpm lint-staged:format",
],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8dee468

Please sign in to comment.