Skip to content

Commit 3b35bb2

Browse files
committed
Fix dockerbuild by using separate Dockerfile + build in dockerignore
1 parent a1d7840 commit 3b35bb2

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/deployment
2+
/build

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ FROM fedora:40@sha256:4e007f288dce23966216be81ef62ba05d139b9338f327c1d1c73b7167d
22

33
RUN dnf -y install gcc-c++ git findutils make cmake
44
COPY . /tmp/pcm
5-
# TEMPORARY change to be remove before merge, to not conflict with local builds + use cache
6-
# WARNING this approach requires me to build locally before docker build to get updated
7-
RUN --mount=type=cache,target=/tmp/pcm/build2 cd /tmp/pcm && cd build2 && cmake -D CMAKE_BUILD_TYPE=Debug .. && make -j pcm pcm-sensor-server
5+
RUN cd /tmp/pcm && mkdir build && cd build && cmake .. && make
86

97
FROM fedora:40@sha256:4e007f288dce23966216be81ef62ba05d139b9338f327c1d1c73b7167dd47312
10-
RUN yum install -y strace gdb util-linux
118
COPY --from=builder /tmp/pcm/build/bin/* /usr/local/bin/
129
ENV PCM_NO_PERF=1
1310

Dockerfile.debug

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM fedora:40@sha256:4e007f288dce23966216be81ef62ba05d139b9338f327c1d1c73b7167dd47312 as builder
2+
3+
RUN dnf -y install gcc-c++ git findutils make cmake strace gdb util-linux
4+
COPY . /tmp/pcm
5+
RUN --mount=type=cache,target=/tmp/pcm/build cd /tmp/pcm/build && cmake -D CMAKE_BUILD_TYPE=Debug ..
6+
RUN --mount=type=cache,target=/tmp/pcm/build cd /tmp/pcm/build && cmake --build . -t pcm -t pcm-sensor-server -t pcm-tpmi && cp -v /tmp/pcm/build/bin/pcm* /bin/
7+
#ENV PCM_NO_PERF=1

deployment/pcm/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,17 @@ chmod +x ~/.docker/cli-plugins/docker-buildx
328328
docker buildx create --driver docker-container --name mydocker --use --bootstrap
329329
330330
# or with single line (from deployment/pcm/ directory)
331-
# Build local image for tests/development + fix /pcm/resctrl mounting (assuming project was configured with cmake previously):
332-
# Note: Warning: we're using patched Dockerfile (TODO to be removed, because "build" directory conflits with existing root "build" directory and for caching ability)
333-
(cd ../.. ; (cd build ; make -j pcm pcm-sensor-server) ; docker build . -t localhost:5001/pcm-local && docker push localhost:5001/pcm-local)
331+
# Build local image for tests/development
332+
# Following Dockerfile contains source code of pcm and some debugging utils (like gdb,strace for further analysis)
333+
(cd ../.. ; docker build . -f Dockerfile.debug -t localhost:5001/pcm-local && docker push localhost:5001/pcm-local)
334334
```
335335

336336
3) When deploying to kind cluster pcm use values to switch to local pcm-local image
337337
```
338338
helm install pcm . -f values-local-image.yaml
339339
```
340340

341-
4) Replace pcm-sensor-server with pcm or sleep
341+
4) Replace pcm-sensor-server with pcm or sleep to be able to run `gdb` or `strace` for example
342342
```
343343
helm upgrade --install pcm . --set debugPcm=true
344344
helm upgrade --install pcm . --set debugSleep=true

0 commit comments

Comments
 (0)