Skip to content

Some docker improvements #27

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
FROM node:14.2
FROM node:14.2 AS build

WORKDIR /app

COPY ./ ./

RUN npm install --only=production


FROM node:14.2 as release

RUN \
apt-get update \
Expand All @@ -21,7 +30,11 @@ RUN \
/root/.cargo/bin/cargo install oxipng

WORKDIR /app

COPY --from=build /app ./

EXPOSE 3000
CMD [ "npm", "run", "installandstartdev" ]

CMD [ "npm", "start" ]

HEALTHCHECK CMD curl -f http://localhost:3000/health || exit 1
31 changes: 31 additions & 0 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM mhart/alpine-node:15 AS base

RUN apk upgrade --no-cache -U && \
apk add --no-cache -t build-dependencies gcc g++ make zlib musl-dev libpng-dev nasm autoconf nss && \
apk add --no-cache chromium freetype freetype-dev harfbuzz ca-certificates ttf-freefont


FROM base AS build

WORKDIR /app

COPY ./ ./

RUN npm install --only=production


FROM base AS release

RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community rust cargo curl && \
cargo install oxipng && \
apk del build-dependencies

WORKDIR /app

COPY --from=build /app ./

EXPOSE 3000

CMD [ "npm", "start" ]

HEALTHCHECK CMD curl -f http://localhost:3000/health || exit 1
14 changes: 14 additions & 0 deletions docker-compose-alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.2"

services:

osmsm:
build:
context: .
dockerfile: Dockerfile-alpine
environment:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
CHROMIUM_PATH: '/usr/bin/chromium-browser'
ports:
- 3000:3000
restart: unless-stopped
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ services:
build: .
ports:
- 3000:3000
volumes:
- .:/app
restart: unless-stopped
1 change: 1 addition & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Browser {
}
async launch() {
return puppeteer.launch({
...process.env.CHROMIUM_PATH && { executablePath: process.env.CHROMIUM_PATH },
args: ["--no-sandbox", "--disable-setuid-sandbox"]
});
}
Expand Down