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

Docker image #159

Open
vincent-tr opened this issue Sep 1, 2021 · 4 comments
Open

Docker image #159

vincent-tr opened this issue Sep 1, 2021 · 4 comments
Assignees
Labels
Feature request Features which are requested by users or collaborators

Comments

@vincent-tr
Copy link

vincent-tr commented Sep 1, 2021

Is your feature request related to a problem? Please describe.
The image published on docker hub is ~900MB.
I'm a bit concerned about that.

Describe the solution you'd like
A smaller image, I guess it should be possible to be a few hundred MB or even less.

Describe alternatives you've considered
I gave a look at other docker hub's tag, and I saw the image was 90MB on v1.xx, and 300MB on v2.0.xx.
I saw that on repo gitconvex-server you managed to use golang:alpine base image instead of golang, and used pre-packaged libraries instead of building them from sources. Is there a reason to not do it in this repo?

Additional context
I suppose it could also be useful to compile go binary like you suggest in Building from source documentation, and only keep binaries in the docker image. Same for UI build.
If needed, I can try to propose a PR on this. Note that I'm not very familiar with go.

@vincent-tr vincent-tr added the Feature request Features which are requested by users or collaborators label Sep 1, 2021
@vincent-tr
Copy link
Author

Note also that the way the docker image is run (without compilation, using go run) seems to makes go engine compile the binary into a temp folder, and then the json configuration file is this temp folder, eg:

# cat /tmp/go-build1056151863/b001/exe/gitconvex_env_config.json
{
 "databaseFile": "/tmp/go-build1056151863/b001/exe//gitconvex-database/repo_datastore.json",
 "port": "9001"
}

This makes the current docker image hard to use to me, because I don't see how to provide configuration to the container.

@vincent-tr
Copy link
Author

vincent-tr commented Sep 1, 2021

I tried using this Dockerfile:

FROM golang:1.16.0-alpine AS builder

WORKDIR /go/src/github.com/neel1996/gitconvex

COPY . .

# Install required packages
RUN apk update && \
    apk add --update libgit2-dev libssh2-dev gcc make nodejs npm musl-dev

# Building server
RUN go get -v && \
    make build-server && \
    mv ./dist/gitconvex-server ./dist/gitconvex

# Building React UI bundle
RUN cd ui/ && \
    npm install && \
    export NODE_ENV=production && \
    npm i -g npm@6 && \
    npm install tailwindcss postcss autoprefixer && \
    npx tailwindcss build -o src/index.css -c src/tailwind.config.js && \
    npm run build && \
    mv build ../dist/gitconvex-ui && \
    cd ..

FROM alpine:latest

WORKDIR /app

RUN apk update && \
    apk add --update libgit2 libssh2

COPY --from=builder /go/src/github.com/neel1996/gitconvex/dist .

EXPOSE 9001

CMD ["./gitconvex"]

The output image seems to work (at least to few I tested), has stable folders (so we can override configuration easily) and is 35MB.

@neel1996
Copy link
Owner

Hi @vincent-tr

You are right. The docker image size is quite large and this has been fixed in the gitconvex-server. I am currently in the process of refactoring the existing api and adding a robust test suite around it.

Once the changes for the server is complete, it will be merged with the gitconvex repo which will optimize the image size (it uses alpine image and alpine packages).

@neel1996
Copy link
Owner

Hi @vincent-tr

Following up on the PR idea for building the binaries as part of dockerization is a good idea and would be the right approach to do it.

You are welcome to propose a PR to the gitconvex-server repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Features which are requested by users or collaborators
Projects
None yet
Development

No branches or pull requests

2 participants