Update docker image for better caching#115
Conversation
We don't have to be afraid of OOM, like inside Docker
|
|
||
| FROM alpine:3.18.3 AS build | ||
|
|
||
| ENV TZ=Europe/London |
There was a problem hiding this comment.
is this necessarry, isn't UTC the default?
| flatbuffers-dev \ | ||
| libsecp256k1-dev \ | ||
| zstd-dev \ | ||
| && rm -rf /var/cache/apk/* \ |
There was a problem hiding this comment.
we already have --no-cache in the runtime build:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
strfry_image_original latest bba6a16b8521 14 seconds ago 143MB
and
REPOSITORY TAG IMAGE ID CREATED SIZE
strfry_image latest 22a7b0451b35 7 minutes ago 143MB
btw, the Ubuntu one is a lot bigger:
REPOSITORY TAG IMAGE ID CREATED SIZE
strfry_image_ubuntu latest 312188f2bc47 3 minutes ago 206MB
| && rm -rf /var/cache/apk/* | ||
| COPY . . | ||
|
|
||
| RUN make clean \ |
There was a problem hiding this comment.
clean was added to the runtime to avoid reusing the local build artefacts
| git submodule update --init | ||
| make setup-golpe | ||
| make -j4 | ||
| make -j$(nproc) |
There was a problem hiding this comment.
we should be able to use all processors when not in a docker image
| @@ -1,4 +1,4 @@ | |||
| FROM ubuntu:jammy as build | |||
| FROM ubuntu:jammy AS build | |||
There was a problem hiding this comment.
to silence the warning
|
|
||
| COPY . . | ||
| # Runtime dependencies | ||
| FROM alpine:3.18.3 AS runtime-deps |
There was a problem hiding this comment.
we can update to 3.20.2 in another PR
| RUN \ | ||
| apk --no-cache add \ | ||
| # Build dependencies | ||
| FROM runtime-deps AS build-deps |
There was a problem hiding this comment.
avoid repeating the image and avoid redownloading the dependencies
|
I tried to build with the Dockerfile from this PR but got errors: |
|
@asoltys, are you able to build on This PR is just reordering the existing image, it's not meant to fix it if it's not working (which can happen if new dependencies aren't compatible anymore). |
|
The ubuntu image worked but I got the same issue with the alpine image when I tried it on the master branch after doing git clean -fxd |
|
i'm seeing a similar error when trying to build on debian trixie |
|
Unfortunately there's a merge conflict. Also, I'd prefer not to change the |
Put the creating of the runtime and compile images before the
copy . .so that they're cached as stable layers, to make sure local changes don't rebuild them.The build image is now built on top of the runtime image, speeding up build time (and making sure the copied files are actually run on the exact same platform).
Also added
make clean, fixed in https://github.com/hoytech/golpe/pull/3/files.These fix the build issue mentioned in #107