Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Docker build container doesn't support sqlite3 #1864
I am trying to build a statically linked buffalo application, using sqlite3, using a scratch runtime container. Using the provided Dockerfile as a template, I'm trying to pre-create the sqlite database in the build container, so I can copy it to the runtime container. However, during the build I get warnings that sqlite3 dialect is not supported, and the sqlite database is not created. It seems that by default, the non-sqlite3 version of buffalo is used in the Docker build image.
Steps to Reproduce the Problem
--- development: dialect: "sqlite3" database: /tmp/portal_development.sqlite test: dialect: "sqlite3" database: /tmp/portal_test.sqlite production: dialect: "sqlite3" database: portal.sqlite
###### Build container ###### FROM gobuffalo/buffalo:v0.15.3 as builder ENV GO111MODULE on RUN apt-get update \ && apt-get install -y upx-ucl RUN mkdir -p $GOPATH/src/portal WORKDIR $GOPATH/src/portal ADD package.json . ADD yarn.lock . RUN yarn install --no-progress ADD . . RUN buffalo pop create -a \ && buffalo build --static -o bin/portal \ && upx -9 bin/portal ###### Deployment container ###### FROM scratch COPY --from=builder /go/src/portal/bin/portal . COPY --from=builder /go/src/portal/portal.sqlite . ENV SESSION_SECRET 'super-secret-session-secret' ENV GO_ENV production ENV ADDR 0.0.0.0 EXPOSE 3000 CMD ["./portal"]
I expected to see a portal.sqlite file be created in the root of my project, which can be copied to the scratch container in the second stage of the Docker build.
I expected the sqlite branch to be the default one for the build container, since it has all the features for all users.
This should at least be documented. Also, the workaround described below could be documented, however it is currently blocked by an issue with the buffalo-goth plugin.
During first stage:
Step 10/18 : RUN buffalo pop create -a && buffalo build --static -o bin/portal && upx -9 bin/portal ---> Running in 60e078a5e527 v4.13.0 [POP] 2019/12/09 16:29:20 warn - unable to load connection development: unsupported dialect 'sqlite3' [POP] 2019/12/09 16:29:20 warn - unable to load connection test: unsupported dialect 'sqlite3' [POP] 2019/12/09 16:29:20 warn - unable to load connection production: unsupported dialect 'sqlite3'
During second stage, the build fails:
Step 13/18 : COPY --from=builder /go/src/portal/portal.sqlite . COPY failed: stat /var/lib/docker/overlay2/f845504b97a69dae77c8a9c77bc2d3bdfe8f46026dcd8496450ddd5add8ea4ec/merged/go/src/portal/portal.sqlite: no such file or directory
The work-around that does work is to (re-)install the pop plugin:
[[plugin]] binary = "buffalo-pop" go_get = "github.com/gobuffalo/buffalo-pop" tags = ["sqlite"]
and in the Dockerfile, in the first stage:
However, I also use Goth, and buffalo-goth currently fails to install because of:
build github.com/gobuffalo/buffalo-goth: cannot load github.com/gobuffalo/genny/movinglater/gotools: module github.com/gobuffalo/genny@latest found (v0.4.1), but does not contain package github.com/gobuffalo/genny/movinglater/gotools
But that is another issue.
I noticed that up until Buffalo v0.14 there actually was an Alpine 'slim' image, which by default had the sqlite tag of buffalo installed; however it is not available any more.