Skip to content

Commit cc74b30

Browse files
committed
works
1 parent 5ffb69b commit cc74b30

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Dockerfile

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ ARG ALGORA_VERSION=0.1.0
1515
ARG ELIXIR_VERSION=1.18.1
1616
ARG OTP_VERSION=27.2
1717
ARG DEBIAN_VERSION=bookworm-20241223-slim
18+
ARG NODE_VERSION=23-bookworm-slim
1819

1920
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
2021
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
22+
ARG NODE_IMAGE="node:${NODE_VERSION}"
2123

2224

2325
FROM ${BUILDER_IMAGE} as builder
@@ -35,7 +37,6 @@ RUN mix local.hex --force && \
3537

3638
# set build ENV
3739
ENV MIX_ENV="prod"
38-
ENV PUPPETEER_CACHE_DIR=/app/puppeteer
3940

4041
# install mix dependencies
4142
COPY mix.exs mix.lock ./
@@ -59,10 +60,6 @@ COPY --from=node:23-bookworm-slim /usr/local/bin /usr/local/bin
5960
# compile assets
6061
RUN mix assets.deploy
6162

62-
# RUN ln -s /usr/local/bin/puppeteer-img /app/lib/algora-${ALGORA_VERSION}/priv/puppeteer-img.js
63-
# RUN chmod u+x /app/lib/algora-${ALGORA_VERSION}/priv/puppeteer-img.js
64-
# TODO: make this runnable via /env/bin/node?
65-
6663
# Compile the release
6764
RUN mix compile
6865

@@ -72,6 +69,10 @@ COPY config/runtime.exs config/
7269
COPY rel rel
7370
RUN mix release
7471

72+
FROM ${NODE_IMAGE} as node
73+
74+
RUN PUPPETEER_CACHE_DIR=/app/puppeteer npx --yes puppeteer browsers install
75+
7576
# start a new build stage so that the final image will only contain
7677
# the compiled release and other runtime necessities
7778
FROM ${RUNNER_IMAGE}
@@ -83,22 +84,8 @@ RUN apt-get update -y && \
8384
# TODO: remove after migration
8485
RUN apt-get update -y && apt-get install -y postgresql-client
8586

86-
# Install Node.js and npm
87-
RUN apt-get update && apt-get install -y ca-certificates curl gnupg
88-
RUN mkdir -p /etc/apt/keyrings
89-
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
90-
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
91-
RUN apt-get update && apt-get install -y nodejs
92-
RUN npm install -n -g npm@latest
93-
9487
COPY --from=node:23-bookworm-slim /usr/local/bin /usr/local/bin
9588

96-
RUN npx puppeteer browsers install
97-
98-
# RUN npm install -g @algora/[email protected]
99-
# RUN npm install -g puppeteer
100-
# RUN npx @puppeteer/browsers install [email protected]
101-
10289
RUN apt-get update -y && apt-get install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
10390

10491
# Set the locale
@@ -118,7 +105,7 @@ ENV MIX_ENV="prod"
118105
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/algora ./
119106

120107
# Copy the puppeteer cache from the build stage
121-
COPY --from=builder --chown=nobody:root /app/puppeteer /app/puppeteer
108+
COPY --from=node --chown=nobody:root /app/puppeteer ./puppeteer
122109

123110
USER nobody
124111

0 commit comments

Comments
 (0)