Skip to content

Commit

Permalink
docker: reduce image size by using multi-stage
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jul 21, 2022
1 parent 70a1fb2 commit 0e33eaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM fedora:36
FROM fedora:36 as base
RUN dnf install -y python3-dasbus python3-pyudev python3-systemd python3-gobject

WORKDIR /root

# first line for nvme-stas
# second line for libnvme
RUN dnf install -y python3-dasbus python3-pyudev python3-systemd python3-gobject meson \
git gcc g++ cmake openssl-devel libuuid-devel json-c-devel swig python-devel meson && dnf clean all
FROM base as builder
RUN dnf install -y git gcc g++ cmake openssl-devel libuuid-devel json-c-devel swig python-devel meson

COPY . .
RUN meson .build && ninja -C .build && meson install -C .build
RUN meson .build && ninja -C .build && meson install -C .build --destdir=/root/stas-dest

FROM base
COPY --from=builder /root/stas-dest /root/stas-dest
ENTRYPOINT ["python3"]
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ services:
environment:
RUNTIME_DIRECTORY: /run/stafd
XDG_CACHE_HOME: /var/cache/stafd
LD_LIBRARY_PATH: /root/stas-dest/usr/lib64
PYTHONPATH: /root/stas-dest/usr/lib64/python3.9/site-packages:/root/stas-dest/usr/lib/python3.9/site-packages
PYTHONUNBUFFERED: 1
command: -u /usr/sbin/stafd
command: -u /root/stas-dest/usr/sbin/stafd --tron
stacd:
<<: *default-stas
environment:
RUNTIME_DIRECTORY: /run/stacd
XDG_CACHE_HOME: /var/cache/stacd
LD_LIBRARY_PATH: /root/stas-dest/usr/lib64
PYTHONPATH: /root/stas-dest/usr/lib64/python3.9/site-packages:/root/stas-dest/usr/lib/python3.9/site-packages
PYTHONUNBUFFERED: 1
command: -u /usr/sbin/stacd
command: -u /root/stas-dest/usr/sbin/stacd --tron

0 comments on commit 0e33eaa

Please sign in to comment.