1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00
dragonflydb-dragonfly/tools/packaging
Roman Gershman cec3659b51
fix: named volume permissions in docker (#3518)
Fixes #2917

The problem is described in this "working as intended" issue https://github.com/moby/moby/issues/3124
So the advised approach of using "USER dfly" directive does not really work because it requires
that the host will also define 'dfly' user with the same id. It's unrealistic expectation.

Therefore, we revert the fix done in #1775 and follow valkey approach:
https://github.com/valkey-io/valkey-container/blob/mainline/docker-entrypoint.sh#L12

1. we run the entrypoint in the container as root which later spawns the dragonfly process
2. if we run as root:
   a. we chmod files under /data to dfly.
   b. use setpriv to exec ourselves as dfly.
3. if we do not run as root we execute the docker command.

So even though the process starts as root, the server runs as dfly and only the bootstrap
part has elevated permissions is used to fix the volume access.

While we are at it, we also switched to setpriv following the change of https://github.com/valkey-io/valkey-container/pull/24/files

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
2024-08-22 11:33:29 +03:00
..
debian fix: logrotate for dragonfly logs (#1972) 2023-10-09 20:08:37 +03:00
rpm Add build_rpm script and rpm spec (#1831) 2023-09-12 10:42:06 +03:00
Dockerfile.alpine-dev fix: named volume permissions in docker (#3518) 2024-08-22 11:33:29 +03:00
Dockerfile.ubuntu-dev fix: named volume permissions in docker (#3518) 2024-08-22 11:33:29 +03:00
Dockerfile.ubuntu-prod fix: named volume permissions in docker (#3518) 2024-08-22 11:33:29 +03:00
generate_changelog.sh feat(actions): add support for debian packaging (#696) 2023-01-18 09:29:28 +02:00
generate_debian_package.sh fix: release pipeline (#2439) 2024-01-18 16:52:19 +02:00
README.md feat(build): debian package building (#689) 2023-01-16 17:44:53 +02:00

Installation Packages

Overview

This directory includes a set of files and scripts to build installation package for various Linux distributions.

Debian

The file to build the Debian package all located under "debian" directory. The resulting package will install the binary of Dragonfly as well as generate a new service entry for dragonfly, that can be controlled with "systemctl" command, to start, stop and check status of.

Building

To build the package, you have a script called "generate_debian_package.sh". This script accepts the following parameters:

  • Optional binary path - the location from which to take the binary for the installation. The default for this is "repo path/build-opt". The location to which the resulting package is writing is at the location from which the script is executed. This script is depends on the following packages:
  • git
  • moreutils
  • debhelper
  • dpkg-dev

To build:

/path/to/dragonfly/tools/packaging/generate_debian_package.sh [/path/to/dragonfly-binary-file]

This can only be run on Debian based hosts. You can use the flowing docker file to generate this package:

FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y && apt-get install -y gcc dpkg-dev gpg vim wget git moreutils debhelper

Build the above docker and then run it with your dragonfly source code path mount as volume for the build:

docker build -t ubuntu-package .
docker run --rm -ti -v /path/to/dragonfly-repo:/mydocker-path ubuntu-package bash

Again note that you need to be at "main" branch to successfully build this package. Note: If at the end of the installation you see a message "/usr/bin/deb-systemd-helper: error: systemctl preset failed on dragonfly.service: No such file or directory", you can ignore it, this seem to be related to the following issue.