-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abbbf8a
commit f941925
Showing
4 changed files
with
107 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: "Docker build" | ||
description: "Build docker html2pdf-service image by its setting" | ||
inputs: | ||
dockerFile: # Docker filename to build | ||
description: "Dockerfile to build" | ||
required: true | ||
default: "docker/chrome/Dockerfile" | ||
imageName: | ||
description: "Image name for tagging" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Build image | ||
run: docker build . --file ${{ input.dockerFile }} --tag ${{ input.imageName }} | ||
|
||
- name: Log into registry | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u $DOCKER_LOGIN --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=appvantage/${{ input.imageName }} | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# Use Docker `latest` tag convention | ||
[ "$VERSION" == "master" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag ${{ input.imageName }} $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
FROM node:18.3.0-bullseye-slim as build | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/local/app | ||
|
||
ENV NODE_ENV=development | ||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
|
||
COPY yarn.lock package.json ./ | ||
|
||
RUN yarn install --frozen-lockfile | ||
|
||
COPY tsconfig.json ./ | ||
COPY src ./src | ||
|
||
RUN yarn build | ||
|
||
ENV NODE_ENV=production | ||
|
||
# install dependencies with frozen lockfile | ||
# then clean with node prune | ||
RUN yarn install --frozen-lockfile --production | ||
|
||
# install node prune | ||
RUN curl -sf https://gobinaries.com/tj/node-prune | sh | ||
|
||
FROM node:18.3.0-bullseye-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y wget gnupg ca-certificates procps libxss1 \ | ||
&& apt-get update \ | ||
# For ARM, google-chrome-stable is not available | ||
# and M1 failed to emulate the chrome browser. | ||
# thus we use chromium for this | ||
&& apt-get install -y chromium \ | ||
# Font settings, currently support for chinese characters | ||
&& apt-get install -y fonts-wqy-zenhei \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/local/app | ||
|
||
ENV PORT=3000 | ||
ENV NODE_ENV=production | ||
# ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome | ||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium | ||
|
||
COPY --from=build /usr/local/app/node_modules ./node_modules | ||
COPY --from=build /usr/local/app/build ./ | ||
|
||
CMD node index.js |