lichess-org / lila-docker

Lichess local development using Docker Compose.
GNU Affero General Public License v3.0
44 stars 44 forks source link

Made an attempt to make docker images lighter. #68

Closed Carbrex closed 7 months ago

Carbrex commented 7 months ago

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 commented 7 months ago

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

Carbrex commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

@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. https://github.com/thoas/picfit/issues/192

fitztrev commented 7 months ago

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 https://github.com/lichess-org/lila-docker/pull/62

Carbrex commented 7 months ago

Its ready.

fitztrev commented 7 months ago

Nice improvement, thanks!