Skip to content

Commit

Permalink
workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
akellbl4 authored and paskal committed Jul 20, 2022
1 parent 2d2f2ab commit 07584ee
Show file tree
Hide file tree
Showing 373 changed files with 843 additions and 895 deletions.
7 changes: 5 additions & 2 deletions .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 All @@ -11,6 +12,9 @@
# source files
docker-compose.yml
rest-client.env.json
compose-private-backend.yml
compose-private-frontend.yml
compose-private.yml

# generated files
*.cov
Expand All @@ -22,4 +26,3 @@ debug.test
*.test
remark42
/backend/var/
compose-private-backend.yml
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
28 changes: 14 additions & 14 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 @@ -52,11 +52,11 @@ jobs:
- name: Install dependencies
run: pnpm i --loglevel warn
working-directory: ./frontend
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 @@ -95,11 +95,11 @@ jobs:
- name: Install dependencies
run: pnpm i --loglevel warn
working-directory: ./frontend
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 @@ -138,11 +138,11 @@ jobs:
- name: Install dependencies
run: pnpm i --loglevel warn
working-directory: ./frontend
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 @@ -181,13 +181,13 @@ jobs:
- name: Install dependencies
run: pnpm i --loglevel warn
working-directory: ./frontend
working-directory: frontend

- 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 }}
4 changes: 2 additions & 2 deletions .github/workflows/ci-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
working-directory: ./site
working-directory: site
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -53,7 +53,7 @@ jobs:
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
working-directory: ./site
working-directory: site
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo "GITHUB_REF=$ref, GITHUB_SHA=${GITHUB_SHA}"
Expand Down
41 changes: 13 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,30 @@ RUN \
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
FROM --platform=$BUILDPLATFORM node:16.15.1-alpine AS build-frontend

ARG CI
ARG SKIP_FRONTEND_BUILD
ARG SKIP_FRONTEND_TEST
ENV HUSKY_SKIP_INSTALL=true

COPY frontend /srv/frontend/

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
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
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
pnpm i; \
fi

WORKDIR /srv/frontend/apps/remark42
RUN \
if [ -z "$SKIP_FRONTEND_TEST" ]; then \
pnpm lint test check; \
pnpm lint type-check translation-check test; \
else \
echo 'Skip frontend test'; \
fi
Expand All @@ -96,7 +81,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
31 changes: 10 additions & 21 deletions Dockerfile.artifacts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
FROM node:16.15.1-alpine as build-frontend-deps

ARG CI
FROM node:16.15.1-alpine as build-frontend

ENV CI=true

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

FROM node:16.15.1-alpine as build-frontend

ARG CI
ARG NODE_ENV=production
ENV HUSKY_SKIP_INSTALL=true

COPY --from=build-frontend-deps /srv/frontend/node_modules /srv/frontend/node_modules
WORKDIR /srv/frontend
RUN npm run build && \
rm -rf ./node_modules
RUN apk add --no-cache --update git && npm i -g pnpm
RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 pnpm i

WORKDIR /srv/frontend/apps/remark42/
ENV NODE_ENV=production
RUN pnpm build

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

Expand All @@ -34,7 +23,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 @@ -46,7 +35,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
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 07584ee

Please sign in to comment.