Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: buildx bake file spec #7

Merged
merged 45 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8424d28
fix: buildx bake file spec
olegstepura Nov 9, 2022
5eb5280
try to run it
olegstepura Nov 9, 2022
04e844d
remove i386
olegstepura Nov 9, 2022
a378fac
try to fix build
olegstepura Nov 9, 2022
2571943
try to fix build
olegstepura Nov 9, 2022
f4e2ed6
try to update puppeteer
olegstepura Nov 9, 2022
c9736ad
update node, downgrade puppeteer
olegstepura Nov 9, 2022
7fe4f7d
try to fix puppeteer on arm
olegstepura Nov 9, 2022
f7d97ce
try to fix puppeteer on arm
olegstepura Nov 9, 2022
dfad070
try to fix puppeteer on arm
olegstepura Nov 9, 2022
a0842a4
try to fix puppeteer on arm
olegstepura Nov 9, 2022
5efc3fc
try to fix puppeteer on arm
olegstepura Nov 9, 2022
13ae7b1
try to fix puppeteer on arm
olegstepura Nov 9, 2022
4e7bb0f
set PUPPETEER_SKIP_DOWNLOAD
olegstepura Nov 9, 2022
2dc7521
fix env args
olegstepura Nov 9, 2022
b53e19b
fix env args
olegstepura Nov 9, 2022
74d841b
fix env args
olegstepura Nov 9, 2022
3f65b02
downgrade puppeteer
olegstepura Nov 9, 2022
4508a25
downgrade puppeteer
olegstepura Nov 9, 2022
8cb9f2c
downgrade puppeteer
olegstepura Nov 9, 2022
8c763b3
try to fix build
olegstepura Nov 9, 2022
d0b4439
try to fix build
olegstepura Nov 9, 2022
3023cd2
try to fix build
olegstepura Nov 9, 2022
6538486
uncomment qemu
olegstepura Nov 9, 2022
be64557
try a fix from https://github.com/actions/setup-node/issues/488#issue…
olegstepura Nov 9, 2022
aece344
no cache
olegstepura Nov 9, 2022
638a097
run lint
olegstepura Nov 9, 2022
8eac7c8
release on merge
olegstepura Nov 9, 2022
30273ab
lint inside container
olegstepura Nov 9, 2022
1afda4d
lint inside container
olegstepura Nov 9, 2022
67f260c
node not needed
olegstepura Nov 9, 2022
0c2a7c1
install for test
olegstepura Nov 9, 2022
f67dc66
skip eslint for prod build
olegstepura Nov 10, 2022
22cf42b
try to rm build file for dev and test
olegstepura Nov 10, 2022
086641d
fix test
olegstepura Nov 10, 2022
9d513a7
remove double build for tests
olegstepura Nov 10, 2022
dcb54cd
skip prod build from linting
olegstepura Nov 10, 2022
671a743
restructure dockerfile
olegstepura Nov 10, 2022
641cf5c
fix eslint
olegstepura Nov 10, 2022
da212cd
try to buildx
olegstepura Nov 10, 2022
7c58e10
fix user
olegstepura Nov 10, 2022
4739608
fix build
olegstepura Nov 10, 2022
6a253c3
revert actions triggers
olegstepura Nov 10, 2022
c12e015
upgrade all remaining deps
olegstepura Nov 10, 2022
1cfa10e
fix linter errors
olegstepura Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ jobs:
runs-on: ubuntu-latest
env:
TAG: html-to-pdf
PUPPETEER_SKIP_DOWNLOAD: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- run: yarn install
- run: yarn lint --max-warnings 0
- name: Build container
run: docker build --file deploy/Dockerfile --target test --tag ${TAG} .
- name: Run lint in a container
run: docker run --rm ${TAG} yarn lint --max-warnings 0
- name: Run test in a container
run: docker run --rm ${TAG} yarn test
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

# https://github.com/docker/buildx/issues/495#issuecomment-1043341496
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
node-version: '16'
cache: 'yarn'
image: tonistiigi/binfmt:qemu-v6.2.0
platforms: amd64,arm64

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
platforms: amd64,arm64

- name: Define docker image metadata
uses: docker/metadata-action@v4
id: meta
Expand All @@ -29,11 +37,13 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=git-,format=short

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/bake-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .npmversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.10.0
8.11.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v15.11.0
v16.16.0
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ vars:
nvm use;
COMPOSE: docker-compose --file deploy/docker-compose.yml

env:
PUPPETEER_SKIP_DOWNLOAD: 1

tasks:
default: task --list

Expand Down
61 changes: 41 additions & 20 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
FROM node:16-alpine as builder

WORKDIR /app
COPY . /app

RUN yarn install && yarn build


FROM alpine:3.16 as prod

ARG RELEASE_ID
ARG CI_BUILD_DATE
ARG CHROME_BIN=/usr/bin/chromium-browser
ARG CHROME_PATH=/usr/lib/chromium/
ARG PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

ENV \
CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/lib/chromium/ \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
RELEASE_ID=$RELEASE_ID \
CI_BUILD_DATE=$CI_BUILD_DATE
FROM alpine:3.16 as base

# Installs latest Chromium package.
RUN \
apk upgrade --no-cache --available \
&& apk add --no-cache \
&& apk add --no-cache \
chromium \
ttf-freefont \
font-noto-emoji \
Expand All @@ -37,6 +24,28 @@ RUN \

WORKDIR /app


FROM base as builder

ENV \
CHROME_BIN=$CHROME_BIN \
CHROME_PATH=$CHROME_PATH \
PUPPETEER_SKIP_DOWNLOAD=1 \
PUPPETEER_EXECUTABLE_PATH=$PUPPETEER_EXECUTABLE_PATH

COPY . /app

RUN yarn install && yarn build


FROM base as prod

ENV \
CHROME_BIN=$CHROME_BIN \
CHROME_PATH=$CHROME_PATH \
RELEASE_ID=$RELEASE_ID \
CI_BUILD_DATE=$CI_BUILD_DATE

COPY deploy/local.conf /etc/fonts/local.conf
COPY --from=builder /app/build/main.prod.js .
COPY favicon.ico .
Expand All @@ -54,24 +63,36 @@ CMD ["/docker-entrypoint.sh"]

FROM prod as dev

ENV \
CHROME_BIN=$CHROME_BIN \
CHROME_PATH=$CHROME_PATH \
RELEASE_ID=$RELEASE_ID \
CI_BUILD_DATE=$CI_BUILD_DATE

# change user to bypass write limitations
USER root

COPY . /app

RUN chown -R chrome ./

# change user back to one used by zenika image
# change user back to default
USER chrome

RUN yarn install


FROM prod as test

ENV \
CHROME_BIN=$CHROME_BIN \
CHROME_PATH=$CHROME_PATH \
RELEASE_ID=$RELEASE_ID \
CI_BUILD_DATE=$CI_BUILD_DATE

# change user to bypass write limitations
USER root

COPY . /app

RUN yarn
RUN yarn install
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ target "docker-metadata-action" {}
target "build" {
inherits = ["docker-metadata-action"]
context = "./"
dockerfile = "deploy/prod/Dockerfile"
dockerfile = "deploy/Dockerfile"
target = "prod"
platforms = [
"linux/386",
"linux/amd64",
"linux/arm64/v8",
]
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
"express": "^4.17.1",
"marked": "^2.1.2",
"prom-client": "^13.1.0",
"puppeteer": "^10.4.0"
"puppeteer": "18.1.0"
},
"devDependencies": {
"@types/express": "^4.17.12",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.4",
"@types/puppeteer": "^5.4.4",
"@types/supertest": "^2.0.11",
"@types/terser-webpack-plugin": "^5.0.3",
"@types/webpack": "^5.28.0",
Expand Down Expand Up @@ -58,6 +57,6 @@
"webpack-cli": "^4.7.2"
},
"engines": {
"node": "~15"
"node": "~16"
}
}
Loading