Skip to content

Commit

Permalink
build: bump docker image base, set node_env=prod (#479)
Browse files Browse the repository at this point in the history
* build: bump docker image base, set node_env=prod

Signed-off-by: rare-magma <[email protected]>

* docs: add release note

Signed-off-by: rare-magma <[email protected]>

* build: use COPY commands

Signed-off-by: rare-magma <[email protected]>

---------

Signed-off-by: rare-magma <[email protected]>
  • Loading branch information
rare-magma authored Nov 3, 2024
1 parent 879869c commit b98ff3f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 37 deletions.
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:18-bullseye as base
FROM node:18-bookworm as base
RUN apt-get update && apt-get install -y openssl
WORKDIR /app
ADD .yarn ./.yarn
ADD yarn.lock package.json .yarnrc.yml ./
COPY .yarn ./.yarn
COPY yarn.lock package.json .yarnrc.yml ./
RUN yarn workspaces focus --all --production

FROM node:18-bullseye-slim as prod
FROM node:18-bookworm-slim as prod
RUN apt-get update && apt-get install tini && apt-get clean -y && rm -rf /var/lib/apt/lists/*

ARG USERNAME=actual
Expand All @@ -16,10 +16,11 @@ RUN groupadd --gid $USER_GID $USERNAME \
RUN mkdir /data && chown -R ${USERNAME}:${USERNAME} /data

WORKDIR /app
ENV NODE_ENV production
COPY --from=base /app/node_modules /app/node_modules
ADD package.json app.js ./
ADD src ./src
ADD migrations ./migrations
COPY package.json app.js ./
COPY src ./src
COPY migrations ./migrations
ENTRYPOINT ["/usr/bin/tini","-g", "--"]
EXPOSE 5006
CMD ["node", "app.js"]
17 changes: 9 additions & 8 deletions docker/edge-alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM alpine:3.17 as base
FROM alpine:3.18 as base
RUN apk add --no-cache nodejs yarn npm python3 openssl build-base jq curl
WORKDIR /app
ADD .yarn ./.yarn
ADD yarn.lock package.json .yarnrc.yml ./
COPY .yarn ./.yarn
COPY yarn.lock package.json .yarnrc.yml ./
RUN if [ "$(uname -m)" = "armv7l" ]; then yarn config set taskPoolConcurrency 2; yarn config set networkConcurrency 5; fi
RUN yarn workspaces focus --all --production
RUN if [ "$(uname -m)" = "armv7l" ]; then npm install bcrypt better-sqlite3 --build-from-source; fi

RUN mkdir /public
ADD artifacts.json /tmp/artifacts.json
COPY artifacts.json /tmp/artifacts.json
RUN jq -r '[.artifacts[] | select(.workflow_run.head_branch == "master" and .workflow_run.head_repository_id == .workflow_run.repository_id)][0]' /tmp/artifacts.json > /tmp/latest-build.json

ARG GITHUB_TOKEN
RUN curl -L -o /tmp/desktop-client.zip --header "Authorization: Bearer ${GITHUB_TOKEN}" $(jq -r '.archive_download_url' /tmp/latest-build.json)
RUN unzip /tmp/desktop-client.zip -d /public

FROM alpine:3.17 as prod
FROM alpine:3.18 as prod
RUN apk add --no-cache nodejs tini

ARG USERNAME=actual
Expand All @@ -25,11 +25,12 @@ RUN addgroup -S ${USERNAME} -g ${USER_GID} && adduser -S ${USERNAME} -G ${USERNA
RUN mkdir /data && chown -R ${USERNAME}:${USERNAME} /data

WORKDIR /app
ENV NODE_ENV production
COPY --from=base /app/node_modules /app/node_modules
COPY --from=base /public /public
ADD package.json app.js ./
ADD src ./src
ADD migrations ./migrations
COPY package.json app.js ./
COPY src ./src
COPY migrations ./migrations
ENTRYPOINT ["/sbin/tini","-g", "--"]
ENV ACTUAL_WEB_ROOT=/public
EXPOSE 5006
Expand Down
17 changes: 9 additions & 8 deletions docker/edge-ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
FROM node:18-bullseye as base
FROM node:18-bookworm as base
RUN apt-get update && apt-get install -y openssl jq
WORKDIR /app
ADD .yarn ./.yarn
ADD yarn.lock package.json .yarnrc.yml ./
COPY .yarn ./.yarn
COPY yarn.lock package.json .yarnrc.yml ./
RUN if [ "$(uname -m)" = "armv7l" ]; then yarn config set taskPoolConcurrency 2; yarn config set networkConcurrency 5; fi
RUN yarn workspaces focus --all --production

RUN mkdir /public
ADD artifacts.json /tmp/artifacts.json
COPY artifacts.json /tmp/artifacts.json
RUN jq -r '[.artifacts[] | select(.workflow_run.head_branch == "master" and .workflow_run.head_repository_id == .workflow_run.repository_id)][0]' /tmp/artifacts.json > /tmp/latest-build.json

ARG GITHUB_TOKEN
RUN curl -L -o /tmp/desktop-client.zip --header "Authorization: Bearer ${GITHUB_TOKEN}" $(jq -r '.archive_download_url' /tmp/latest-build.json)
RUN unzip /tmp/desktop-client.zip -d /public

FROM node:18-bullseye-slim as prod
FROM node:18-bookworm-slim as prod
RUN apt-get update && apt-get install tini && apt-get clean -y && rm -rf /var/lib/apt/lists/*

ARG USERNAME=actual
Expand All @@ -25,11 +25,12 @@ RUN groupadd --gid $USER_GID $USERNAME \
RUN mkdir /data && chown -R ${USERNAME}:${USERNAME} /data

WORKDIR /app
ENV NODE_ENV production
COPY --from=base /app/node_modules /app/node_modules
COPY --from=base /public /public
ADD package.json app.js ./
ADD src ./src
ADD migrations ./migrations
COPY package.json app.js ./
COPY src ./src
COPY migrations ./migrations
ENTRYPOINT ["/usr/bin/tini","-g", "--"]
ENV ACTUAL_WEB_ROOT=/public
EXPOSE 5006
Expand Down
15 changes: 8 additions & 7 deletions docker/stable-alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM alpine:3.17 as base
FROM alpine:3.18 as base
RUN apk add --no-cache nodejs yarn npm python3 openssl build-base
WORKDIR /app
ADD .yarn ./.yarn
ADD yarn.lock package.json .yarnrc.yml ./
COPY .yarn ./.yarn
COPY yarn.lock package.json .yarnrc.yml ./
RUN if [ "$(uname -m)" = "armv7l" ]; then yarn config set taskPoolConcurrency 2; yarn config set networkConcurrency 5; fi
RUN yarn workspaces focus --all --production
RUN if [ "$(uname -m)" = "armv7l" ]; then npm install bcrypt better-sqlite3 --build-from-source; fi

FROM alpine:3.17 as prod
FROM alpine:3.18 as prod
RUN apk add --no-cache nodejs tini

ARG USERNAME=actual
Expand All @@ -17,10 +17,11 @@ RUN addgroup -S ${USERNAME} -g ${USER_GID} && adduser -S ${USERNAME} -G ${USERNA
RUN mkdir /data && chown -R ${USERNAME}:${USERNAME} /data

WORKDIR /app
ENV NODE_ENV production
COPY --from=base /app/node_modules /app/node_modules
ADD package.json app.js ./
ADD src ./src
ADD migrations ./migrations
COPY package.json app.js ./
COPY src ./src
COPY migrations ./migrations
ENTRYPOINT ["/sbin/tini","-g", "--"]
EXPOSE 5006
CMD ["node", "app.js"]
15 changes: 8 additions & 7 deletions docker/stable-ubuntu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:18-bullseye as base
FROM node:18-bookworm as base
RUN apt-get update && apt-get install -y openssl
WORKDIR /app
ADD .yarn ./.yarn
ADD yarn.lock package.json .yarnrc.yml ./
COPY .yarn ./.yarn
COPY yarn.lock package.json .yarnrc.yml ./
RUN if [ "$(uname -m)" = "armv7l" ]; then yarn config set taskPoolConcurrency 2; yarn config set networkConcurrency 5; fi
RUN yarn workspaces focus --all --production

FROM node:18-bullseye-slim as prod
FROM node:18-bookworm-slim as prod
RUN apt-get update && apt-get install tini && apt-get clean -y && rm -rf /var/lib/apt/lists/*

ARG USERNAME=actual
Expand All @@ -17,10 +17,11 @@ RUN groupadd --gid $USER_GID $USERNAME \
RUN mkdir /data && chown -R ${USERNAME}:${USERNAME} /data

WORKDIR /app
ENV NODE_ENV production
COPY --from=base /app/node_modules /app/node_modules
ADD package.json app.js ./
ADD src ./src
ADD migrations ./migrations
COPY package.json app.js ./
COPY src ./src
COPY migrations ./migrations
ENTRYPOINT ["/usr/bin/tini","-g", "--"]
EXPOSE 5006
CMD ["node", "app.js"]
6 changes: 6 additions & 0 deletions upcoming-release-notes/479.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [rare-magma]
---

Updates the docker images base version and set node_env env variable to production

0 comments on commit b98ff3f

Please sign in to comment.