-
Notifications
You must be signed in to change notification settings - Fork 112
Docker Option for openmaxio #26
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
base: openMaxIO-main
Are you sure you want to change the base?
Conversation
|
Based on how minio had setup the build system, it'll probably be better for now just to use the Makefile. Also while the example is good to have, it probably belongs more in the docs folder. In this case, I would also make the example not use certificates and leave that up to the end users. I'll make an PR to address most of this in a minute |
|
I am also a fan of using Not sure if you followed the discussion in #8 but additional to multi-stage build you would also make use of caching layers to speed up builds from things that haven’t changed between builds. ARG GO_VERSION=1.24
ARG NODE_VERSION=24
FROM node:${NODE_VERSION}-alpine AS uilayer
WORKDIR /app
# Git is required for some dependencies pulled from repositories
RUN apk add --no-cache git
RUN corepack enable && corepack prepare yarn@4.4.0 --activate
COPY ./web-app/package.json ./web-app/yarn.lock ./web-app/.yarnrc.yml ./
RUN yarn install
COPY ./web-app .
RUN yarn build
USER node
FROM golang:${GO_VERSION}-alpine AS golayer
WORKDIR /console/
ADD go.mod .
ADD go.sum .
# Get dependencies - will also be cached if we won't change mod/sum
RUN go mod download
ADD . .
ENV CGO_ENABLED=0
ENV GO111MODULE=on
COPY --from=uilayer /app/build ./web-app/build
RUN go build -trimpath --tags=kqueue,operator -ldflags "-w -s" -a -o console ./cmd/console
FROM scratch
EXPOSE 9090
COPY --from=golayer /console/console .
ENTRYPOINT ["/console"]
CMD [ "server"]The important parts are copying only the package files over before installing dependencies and then the rest for builds. node_modules/
dist/
target/
console
!console/
web-app/node_modules/
.git/As example you can take a look at the dockerfiles used by minio before they removed them: 1058efb Tip You can use docker build -t ghcr.io/georgmangold/console:dev --output type=local,dest=./dist . |
|
Use a slim version of node image and remove all of those RUN lines and merge them into one to reduce layers. Consider using multi staging and introduce some env vars. |
This is a much cleaner version of the docker build I submitted in:
#25
While the changes are very minimal, the image size went from ~5GB to less then 100MB by doing a multi-stage build and I fixed an nginx config issue where it only allowed >1mb size files and the bucket browser didn't work due to nginx not allowing websockets