Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: reduce image size by using multi-stage #194

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.10/site-packages:/root/stas-dest/usr/lib/python3.10/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.10/site-packages:/root/stas-dest/usr/lib/python3.10/site-packages
PYTHONUNBUFFERED: 1
command: -u /usr/sbin/stacd
command: -u /root/stas-dest/usr/sbin/stacd --tron