Skip to content
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

Made an attempt to make docker images lighter. #68

Merged
merged 14 commits into from
Mar 29, 2024

Conversation

Carbrex
Copy link
Member

@Carbrex Carbrex commented Mar 26, 2024

I have made changes to some docker files to reduce their size.
You dont need to merge this. I was just trying to reduce the size you can incorporate the changes you want.

These are the comparisons before and after changes:

Before changes:

docker images
d1
docker stats
image

After changes:

docker images
d3
docker stats
d4

To make an sbt image for alpine I took this https://github.com/buildo/scala-sbt-alpine/blob/master/Dockerfile and made some changes to this. It works just fine and lila and lila-fishnet work fine too.
I think the ui.Dockerfile can be taken as it is. It works well with chessground and pgn-viewer also.

@fitztrev
Copy link
Member

Looking great, thanks! Yeah if you want to split out the updates to the node-based images, those could be merged.

@Carbrex
Copy link
Member Author

Carbrex commented Mar 26, 2024

I think the only node based image is the ui one. You can just copy paste the changes from this pr I dont think we need a pr for that.

@Carbrex
Copy link
Member Author

Carbrex commented Mar 29, 2024

Reduced the size of picfit image in this commit but the image build process downloads 1GB data. So, I uploaded this image on docker and now the build time is reduced pretty much. Either we can use it carbrex/thoas-picfit:latest as it is or upload on docker hub under lichess and then use it?

# Build stage
FROM golang:1.22.1-alpine3.19 AS build

RUN apk --no-cache add git make

WORKDIR /opt

RUN git clone --depth 1 https://github.com/thoas/picfit.git
RUN make -C /opt/picfit build

# Runtime stage
FROM alpine:3.19

COPY --from=build /opt/picfit/bin/picfit /picfit

ENTRYPOINT ["/picfit"]

@Carbrex
Copy link
Member Author

Carbrex commented Mar 29, 2024

Before:
image
After:
image

Changes:
lila-docker-picfit: 1.39GB -> 50.3MB
lila-docker-lila_fishnet: 977MB->792MB
lila-docker-lila: 977MB->792MB
lila-docker-lila_ws: 977MB->792MB
lila-docker-lila_search: 945MB->760MB
lila-docker-ui: 1.12GB->347MB

@fitztrev
Copy link
Member

@Carbrex it looks like thoas/picfit has started updating their docker hub image again with the latest release. Could we use that as the base image?

@Carbrex
Copy link
Member Author

Carbrex commented Mar 29, 2024

@Carbrex it looks like thoas/picfit has started updating their docker hub image again with the latest release. Could we use that as the base image?

Yes, I saw that but it only supports arm for now. I have filed an issue on github, we can wait for it to get resolved. thoas/picfit#192

@fitztrev
Copy link
Member

I'm OK to merge now if it's ready?

We can use your hosted image for now. At some point maybe we can move it to be hosted by ghcr, like I'm doing with #62

@Carbrex Carbrex marked this pull request as ready for review March 29, 2024 14:14
@Carbrex
Copy link
Member Author

Carbrex commented Mar 29, 2024

Its ready.

@fitztrev fitztrev merged commit 026ac7e into lichess-org:main Mar 29, 2024
2 checks passed
@fitztrev
Copy link
Member

Nice improvement, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants