Skip to content

Commit

Permalink
Merge pull request hardillb#11 from cas--/slim-docker-image
Browse files Browse the repository at this point in the history
Create smaller docker images
  • Loading branch information
hardillb committed Aug 27, 2023
2 parents 3cd0a39 + a10b8de commit 5b59bad
Show file tree
Hide file tree
Showing 3 changed files with 447 additions and 858 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
node_modules
.git
.gitignore
.github
Dockerfile
*.md
LICENSE
44 changes: 34 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
FROM python:3.9.16-alpine3.17
FROM python:3.10.10-alpine3.17 as base
LABEL maintainer="Ben Hardill [email protected]"
RUN apk add --no-cache --update \
dbus-libs \
'nodejs<19'

RUN \
apk add --update autoconf automake make cmake pkgconfig gcc libc-dev g++ glib-dev linux-headers dbus dbus-dev && \
apk add --update 'nodejs<19' 'npm<10' && \
pip install -U pip && pip install pipenv && \
rm -rf /var/lib/apt/lists/*
# Install dependencies
FROM base as compile-image

WORKDIR /usr/src/app

COPY . .
RUN pip install mdns-publisher && \
npm install
RUN apk add --no-cache --update \
cmake \
g++ \
glib-dev \
dbus \
dbus-dev \
glib-dev \
'npm<10' && \
pip install --upgrade --no-cache-dir pip

CMD ["npm", "start"]
RUN pip install --user --no-cache-dir mdns-publisher

COPY package.json package-lock.json .
RUN npm ci --production

# Build application
FROM base as build-image

WORKDIR /usr/src/app

# app
COPY cname.py index.js .
# npm packages
COPY --from=compile-image /usr/src/app/node_modules node_modules
# pip packages
COPY --from=compile-image /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH

CMD ["node", "index.js"]
Loading

0 comments on commit 5b59bad

Please sign in to comment.