Skip to content

Commit

Permalink
Setup dockle & corepack pack (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Nov 8, 2024
1 parent 95e4f02 commit 9b71bf4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/dockle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Dockle

on:
push:
branches:
- main
pull_request:

jobs:
dockle:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build an image from Dockerfile
uses: docker/build-push-action@v6
with:
context: .
push: false
provenance: false
tags: |
summaly:scan
- name: Run dockle
uses: docker://goodwithtech/dockle:v0.4.14
env:
DOCKLE_OUTPUT_FORMAT: list
DOCKLE_EXIT_CODE: 1
DOCKLE_EXIT_LEVEL: WARN
DOCKLE_IGNORES: CIS-DI-0005,CIS-DI-0010
DOCKLE_DEBUG: true
with:
args: 'summaly:scan'
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
FROM node:20-slim
# syntax = docker/dockerfile:1.4

ARG NODE_VERSION=20

FROM --platform=$TARGETPLATFORM node:${NODE_VERSION}-slim

ARG UID="991"
ARG GID="991"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libjemalloc-dev libjemalloc2 \
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
&& corepack enable \
&& groupadd -g "${GID}" summaly \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /app summaly \
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; \
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists

USER summaly
WORKDIR /app
COPY --chown=summaly:summaly . ./

ENV NODE_ENV=production

COPY ./ ./
RUN corepack enable \
&& pnpm i --frozen-lockfile --aggregate-output \
&& pnpm install fastify-cli
RUN pnpm i --frozen-lockfile --aggregate-output
RUN pnpm install fastify-cli

RUN corepack pack
ENV COREPACK_ENABLE_NETWORK=0

ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
ENV MALLOC_CONF=background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,muzzy_decay_ms:30000

CMD ["pnpm", "fastify", "start", "./dist/index.js"]

Expand Down

0 comments on commit 9b71bf4

Please sign in to comment.