utkarsh-1905 / time-table

Thapar University Time Table Generator App
https://timetable.mlsctiet.com
GNU General Public License v3.0
65 stars 21 forks source link

Reduce the size of Docker image #26

Open utkarsh-1905 opened 1 year ago

utkarsh-1905 commented 1 year ago

In the previous release, the docker image was built on top of the scratch image and worked fine. But after committing 599ee682edc6b921a2743f00e50307360443ec24, the image built using the previous docker file shows an invalid pointer dereference error, but it is working fine on the full-size go-alpine image.

Image size increased from 15MB -> 450MB

ItsMeSamey commented 3 months ago

this seems to run fine for me: checked out the previous commit too, same thing

FROM golang:1.20.4-alpine AS build
WORKDIR /app

COPY ./ ./
RUN go mod download

RUN go build main.go

LABEL traefik.port=80
LABEL traefik.http.routers.tt.rule="Host(`timetable.mlsctiet.com`)"
LABEL traefik.http.routers.tt.tls=true
LABEL traefik.http.routers.tt.tls.certresolver="lets-encrypt"
LABEL org.opencontainers.image.source="https://github.com/utkarsh-1905/time-table"

FROM scratch
WORKDIR /app

COPY --from=build /app/main ./
COPY --from=build /app/data.json ./
COPY --from=build /app/timetable.xlsx ./

# if deployed on personal server
EXPOSE 3000
CMD ["./main"]