-
Notifications
You must be signed in to change notification settings - Fork 100
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
Update docker image for better caching #115
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessarry, isn't UTC the default?
@@ -24,25 +24,24 @@ RUN \ | |||
lmdb-dev \ | |||
flatbuffers-dev \ | |||
libsecp256k1-dev \ | |||
zstd-dev \ | |||
&& rm -rf /var/cache/apk/* \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean was added to the runtime to avoid reusing the local build artefacts
@@ -35,15 +35,15 @@ A C++20 compiler is required, along with a few other common dependencies. On Deb | |||
git clone https://github.com/hoytech/strfry && cd strfry/ | |||
git submodule update --init | |||
make setup-golpe | |||
make -j4 | |||
make -j$(nproc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to silence the warning
|
||
COPY . . | ||
# Runtime dependencies | ||
FROM alpine:3.18.3 AS runtime-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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