Skip to content

Commit 0a2908a

Browse files
nightkrrazvan
andauthored
Add Kerberos libraries to the Docker images (#242)
* Include all binary outputs from the workspace in the images' $PATH * Include MIT kerberos libraries in the build- and runtime environments * Document why the different Nix components are installed * Install krb5 for CI * Also install krb5 headers for CI * Consider all workspace members for udeps * Fix wonky Dockerfile COPY path * Add undo-tree files to the Tilt ignore list --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent 1b42579 commit 0a2908a

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

template/.github/workflows/build.yml.j2

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
env:
3232
RUSTC_BOOTSTRAP: 1
3333
steps:
34-
- name: Install protoc
34+
- name: Install host dependencies
3535
run: |
3636
sudo apt-get update
37-
sudo apt-get install protobuf-compiler
37+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
3838
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
3939
with:
4040
submodules: recursive
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
key: udeps
4545
- run: cargo install cargo-udeps
46-
- run: cargo udeps
46+
- run: cargo udeps --workspace
4747

4848
# This job evaluates the github environment to determine why this action is running and selects the appropriate
4949
# target repository for published Helm charts based on this.
@@ -125,10 +125,10 @@ jobs:
125125
name: Run Clippy
126126
runs-on: ubuntu-latest
127127
steps:
128-
- name: Install protoc
128+
- name: Install host dependencies
129129
run: |
130130
sudo apt-get update
131-
sudo apt-get install protobuf-compiler
131+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
132132
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
133133
with:
134134
submodules: recursive
@@ -156,10 +156,10 @@ jobs:
156156
name: Run RustDoc
157157
runs-on: ubuntu-latest
158158
steps:
159-
- name: Install protoc
159+
- name: Install host dependencies
160160
run: |
161161
sudo apt-get update
162-
sudo apt-get install protobuf-compiler
162+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
163163
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
164164
with:
165165
submodules: recursive
@@ -175,10 +175,10 @@ jobs:
175175
name: Run Cargo Tests
176176
runs-on: ubuntu-latest
177177
steps:
178-
- name: Install protoc
178+
- name: Install host dependencies
179179
run: |
180180
sudo apt-get update
181-
sudo apt-get install protobuf-compiler
181+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
182182
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
183183
with:
184184
submodules: recursive
@@ -230,10 +230,10 @@ jobs:
230230
name: Check if committed Helm charts are up to date
231231
runs-on: ubuntu-latest
232232
steps:
233-
- name: Install protoc
233+
- name: Install host dependencies
234234
run: |
235235
sudo apt-get update
236-
sudo apt-get install protobuf-compiler
236+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
237237
- name: Checkout
238238
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
239239
with:
@@ -288,10 +288,10 @@ jobs:
288288
outputs:
289289
IMAGE_TAG: ${{ steps.printtag.outputs.IMAGE_TAG }}
290290
steps:
291-
- name: Install protoc
291+
- name: Install host dependencies
292292
run: |
293293
sudo apt-get update
294-
sudo apt-get install protobuf-compiler
294+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev
295295
- name: Checkout
296296
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
297297
with:

template/Tiltfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ custom_build(
1212
registry + '/' + operator_name,
1313
'nix shell -f . crate2nix -c crate2nix generate && nix-build . -A docker --argstr dockerName "${EXPECTED_REGISTRY}/' + operator_name + '" && ./result/load-image | docker load',
1414
deps=['rust', 'Cargo.toml', 'Cargo.lock', 'default.nix', "nix", 'build.rs', 'vendor'],
15+
ignore=['*.~undo-tree~'],
1516
# ignore=['result*', 'Cargo.nix', 'target', *.yaml],
1617
outputs_image_ref_to='result/ref',
1718
)

template/default.nix

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
tonic-reflection = attrs: {
1111
buildInputs = [ pkgs.rustfmt ];
1212
};
13+
stackable-secret-operator = attrs: {
14+
buildInputs = [ pkgs.protobuf pkgs.rustfmt ];
15+
};
16+
krb5-sys = attrs: {
17+
nativeBuildInputs = [ pkgs.pkg-config ];
18+
buildInputs = [ (pkgs.enableDebugging pkgs.krb5) ];
19+
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
20+
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.glibc.dev}/include -I${pkgs.clang.cc.lib}/lib/clang/${pkgs.lib.getVersion pkgs.clang.cc}/include";
21+
};
1322
};
1423
}
1524
, meta ? pkgs.lib.importJSON ./nix/meta.json
@@ -27,14 +36,21 @@ rec {
2736
dockerImage = pkgs.dockerTools.streamLayeredImage {
2837
name = dockerName;
2938
tag = dockerTag;
30-
contents = [ pkgs.bashInteractive pkgs.coreutils pkgs.util-linuxMinimal ];
39+
contents = [
40+
# Common debugging tools
41+
pkgs.bashInteractive pkgs.coreutils pkgs.util-linuxMinimal
42+
# Kerberos 5 must be installed globally to load plugins correctly
43+
pkgs.krb5
44+
# Make the whole cargo workspace available on $PATH
45+
build
46+
];
3147
config = {
32-
Env =
33-
let
34-
fileRefVars = {
35-
PRODUCT_CONFIG = deploy/config-spec/properties.yaml;
36-
};
37-
in pkgs.lib.concatLists (pkgs.lib.mapAttrsToList (env: path: pkgs.lib.optional (pkgs.lib.pathExists path) "${env}=${path}") fileRefVars);
48+
Env =
49+
let
50+
fileRefVars = {
51+
PRODUCT_CONFIG = deploy/config-spec/properties.yaml;
52+
};
53+
in pkgs.lib.concatLists (pkgs.lib.mapAttrsToList (env: path: pkgs.lib.optional (pkgs.lib.pathExists path) "${env}=${path}") fileRefVars);
3854
Entrypoint = [ entrypoint ];
3955
Cmd = [ "run" ];
4056
};

template/docker/Dockerfile.j2

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ RUN microdnf install -y yum \
2323
&& yum clean all \
2424
&& microdnf clean all
2525

26+
# Install kerberos client libraries
27+
RUN microdnf install -y krb5-libs libkadm5 && microdnf clean all
28+
2629
COPY LICENSE /licenses/LICENSE
2730

28-
COPY --from=builder /app/stackable-{[ operator.name }] /
31+
COPY --from=builder /app/* /usr/local/bin/
2932
{[% if operator.include_productconfig is undefined or operator.include_productconfig == true %}]
3033
COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.name }]/config-spec/properties.yaml
3134
{[% endif %}]
@@ -34,5 +37,5 @@ RUN groupadd -g 1000 stackable && adduser -u 1000 -g stackable -c 'Stackable Ope
3437

3538
USER stackable:stackable
3639

37-
ENTRYPOINT ["/stackable-{[ operator.name }]"]
40+
ENTRYPOINT ["stackable-{[ operator.name }]"]
3841
CMD ["run"]

0 commit comments

Comments
 (0)