Skip to content

Commit

Permalink
Try using Docker node slim instead of alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Aug 2, 2024
1 parent 70cdb44 commit 399c1f5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
34 changes: 24 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG TARGET
ARG VERSION
ARG BUILD_DATE

FROM $TARGET/node:18-alpine
FROM ${TARGET}/node:18-slim

LABEL \
org.label-schema.build-date=$BUILD_DATE \
Expand All @@ -11,28 +11,42 @@ LABEL \
COPY qemu-* /usr/bin/

# System dependencies
RUN apk add --no-cache tzdata nmap ffmpeg sqlite openssl gzip eudev gcompat
RUN apt-get update && apt-get install -y \
tzdata \
nmap \
ffmpeg \
sqlite3 \
openssl \
gzip \
udev \
bluez \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp

# Install Bluez dependencies
RUN apk add --no-cache bluez

# Install Gladys
RUN mkdir /src
WORKDIR /src
ADD . /src
COPY ./static /src/server/static
WORKDIR /src/server
RUN apk add --no-cache --virtual .build-deps make gcc g++ python3 py3-setuptools git libffi-dev linux-headers libc6-compat \
&& npm ci --unsafe-perm --production \
&& npm cache clean --force \
&& apk del .build-deps

# Install build dependencies and application dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3 \
python3-pip \
git \
libffi-dev \
&& npm ci --unsafe-perm --production \
&& npm cache clean --force \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

ENV NODE_ENV production
ENV SERVER_PORT 80

# Export listening port
EXPOSE 80

CMD ["node", "index.js"]
CMD ["node", "index.js"]
30 changes: 18 additions & 12 deletions docker/Dockerfile.buildx
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
# STEP 1
# Prepare server package*.json files
FROM node:18-alpine as json-files
FROM node:18-slim as json-files
COPY ./server /json-files/server
WORKDIR /json-files/server/
RUN find . -type f \! -name "package*.json" -exec rm -r {} \;
COPY ./server/cli /json-files/server/cli
COPY ./server/utils /json-files/server/utils


# STEP 3
# Gladys Bundle
FROM node:18-alpine as gladys
FROM node:18-slim as gladys

# System dependencies
RUN apk add --no-cache \
RUN apt-get update && apt-get install -y \
tzdata \
nmap \
ffmpeg \
sqlite \
sqlite3 \
openssl \
gzip \
eudev \
gcompat \
bluez
udev \
bluez \
&& rm -rf /var/lib/apt/lists/*

COPY --from=json-files /json-files/server /src/server

ENV LD_LIBRARY_PATH /lib

WORKDIR /src/server

RUN apk add --no-cache --virtual .build-deps make gcc g++ python3 py3-setuptools git libffi-dev linux-headers \
&& npm ci --unsafe-perm --production \
&& npm cache clean --force \
&& apk del .build-deps
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3 \
python3-pip \
git \
libffi-dev \
&& npm ci --unsafe-perm --production \
&& npm cache clean --force \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*

# Copy builded front
COPY ./static /src/server/static
Expand Down

0 comments on commit 399c1f5

Please sign in to comment.