Skip to content

Commit

Permalink
1145 Upgrade yarn to v3 (podkrepi-bg#1189)
Browse files Browse the repository at this point in the history
* Upgrade yarn and update dockerfile

* Auto format

* Added curl to the container

* Change cmd to get cache folder

* Ignore yarn folder when searching with vscode

* Switch workflows to node 18 and add yarn cache

* Remove yarn cache from unit tests workflow

* Remove yarn ache expectation from api repo
  • Loading branch information
kachar authored Nov 25, 2022
1 parent 17bbfa8 commit 618ffcd
Show file tree
Hide file tree
Showing 21 changed files with 13,514 additions and 8,392 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
2 changes: 1 addition & 1 deletion .github/workflows/build-nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
GHOST_CONTENT_KEY: ${{ secrets.GHOST_CONTENT_KEY }}
with:
push: false
target: production
target: runner
build-args: |
SENTRY_AUTH_TOKEN=${{ env.SENTRY_AUTH_TOKEN }}
GHOST_API_URL=${{ env.GHOST_API_URL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
Expand All @@ -37,7 +37,7 @@ jobs:
run: docker compose up -d pg-db
- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18'

- name: Install backend dependencies and seed database
working-directory: ./api
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
GHOST_CONTENT_KEY: ${{ secrets.GHOST_CONTENT_KEY }}
with:
push: true
target: production
target: runner
build-args: |
SENTRY_AUTH_TOKEN=${{ env.SENTRY_AUTH_TOKEN }}
GHOST_API_URL=${{ env.GHOST_API_URL }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Component Tests

on:
workflow_dispatch:
Expand All @@ -12,7 +12,7 @@ jobs:
strategy:
max-parallel: 1
matrix:
node-version: [14.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -24,7 +24,7 @@ jobs:

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
Expand Down
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ coverage
.settings/
*.sublime-workspace
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.vs

.env
Expand All @@ -50,3 +54,12 @@ bld/
/test-results/
/playwright-report/
/playwright/.cache/

# https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ package-lock.json
public/fonts
public/img
manifests
.github
!.github/workflows
.yarn
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"**/.yarn": true
},
"search.exclude": {
"**/.yarn": true
},
"files.watcherExclude": {
"**/.yarn": true
}
}
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

550 changes: 550 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

807 changes: 807 additions & 0 deletions .yarn/releases/yarn-3.3.0.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

11 changes: 11 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: '@yarnpkg/plugin-version'
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'

yarnPath: .yarn/releases/yarn-3.3.0.cjs
57 changes: 28 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,61 @@ WORKDIR /app
ARG NODE_ENV=production
ENV PATH=/app/node_modules/.bin:$PATH \
NODE_ENV="$NODE_ENV"
COPY package.json yarn.lock /app/
EXPOSE 3040

# Build target dependencies #
###########################
FROM base AS dependencies
# Yarn
RUN yarn set version berry
COPY package.json yarn.lock* .yarnrc.yml ./

RUN apk --no-cache add curl g++ make python3

# Install prod dependencies
RUN yarn install --production && \
# Cache prod dependencies
cp -R node_modules /prod_node_modules && \
# Install dev dependencies
yarn install --production=false
FROM base AS deps

# Build target development #
############################
FROM dependencies AS development
COPY . /app
CMD [ "yarn", "dev" ]
COPY .yarn .yarn
RUN yarn workspaces focus --all --production

# Build target builder #
########################
FROM base AS builder

# Setup build env
ARG VERSION=unversioned
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN"
ARG GHOST_API_URL
ENV GHOST_API_URL="$GHOST_API_URL"
ARG GHOST_CONTENT_KEY
ENV GHOST_CONTENT_KEY="$GHOST_CONTENT_KEY"
COPY --from=dependencies /app/node_modules /app/node_modules
COPY . /app

RUN apk add --no-cache jq && \
mv package.json package.json.bak && \
jq --arg version "$VERSION" '.version=$version' package.json.bak > package.json && \
rm package.json.bak && \
apk del jq

# Add dev deps
COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN yarn build && \
yarn sitemap && \
rm -rf node_modules
yarn sitemap

# Build target production #
###########################
FROM base AS production
FROM base AS runner

COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public
COPY --from=dependencies /prod_node_modules /app/node_modules
COPY next.config.js next-i18next.config.js /app/
RUN apk --no-cache add curl

USER 1000:1001
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

ENV PORT 3040

EXPOSE 3040

CMD [ "yarn", "start" ]
CMD [ "node", "server.js" ]

HEALTHCHECK --interval=5s --timeout=3s --retries=3 CMD curl --fail http://localhost:3040 || exit 1
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ Read more at [End-2-End Testing](https://github.com/podkrepi-bg/frontend/blob/ma
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-60-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for:
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.7'
services:
frontend:
image: frontend
container_name: frontend
build:
context: ./
dockerfile: ./Dockerfile
# args:
# SENTRY_AUTH_TOKEN: ${SENTRY_AUTH_TOKEN}
# GHOST_API_URL: ${GHOST_API_URL}
# GHOST_CONTENT_KEY: ${GHOST_CONTENT_KEY}
env_file:
- .env.local
ports:
- '3040:3040'
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const moduleExports = {
includePaths: [path.join(__dirname, 'src/styles')],
},
swcMinify: true,
output: 'standalone',
env: {
APP_ENV: process.env.APP_ENV,
APP_VERSION: version,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.9.13",
"license": "MIT",
"repository": "https://github.com/orgs/podkrepi-bg",
"packageManager": "[email protected]",
"scripts": {
"predev": "shx test -e .env.local && exit 0 || shx echo 'You need to create .env.local file. Please check README.md!' && exit 1",
"dev": "yarn && next dev -p 3040",
Expand Down
Loading

0 comments on commit 618ffcd

Please sign in to comment.