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 build container doesn't support sqlite3 #1864

Open
bjwschaap opened this issue Dec 9, 2019 · 0 comments
Open

Docker build container doesn't support sqlite3 #1864

bjwschaap opened this issue Dec 9, 2019 · 0 comments

Comments

@bjwschaap
Copy link

@bjwschaap bjwschaap commented Dec 9, 2019

Description

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

  1. Create sample application with Buffalo (sqlite tag)
  2. In database.yml:
---
development:
  dialect: "sqlite3"
  database: /tmp/portal_development.sqlite

test:
  dialect: "sqlite3"
  database: /tmp/portal_test.sqlite

production:
  dialect: "sqlite3"
  database: portal.sqlite
  1. Using the following Dockerfile:
###### 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"]
  1. Then issue docker build -t portal .

Expected Behavior

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.

Actual Behavior

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

Info

-> Go: Checking installation
✓ The `go` executable was found on your system at: /usr/local/go/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.13.4, meets the minimum requirements.

-> Go: Checking GOPATH
✓ You appear to be operating inside of your GOPATH.

-> Go: Checking Package Management
⚠ You do not appear to be using a package management system.

It is strongly suggested that you use one of the following package management systems:

* Go Modules (Recommended) - https://gobuffalo.io/en/docs/gomods
* Dep - https://github.com/golang/dep

For help setting up your Go environment please follow the instructions for you platform at:

https://www.gopherguides.com/courses/preparing-your-environment-for-go-development

-> Go: Checking PATH
✓ Your PATH contains /go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /usr/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v10.17.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /usr/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.11.3, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /usr/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.19.2, meets the minimum requirements.

-> PostgreSQL: Checking installation
✘ The `postgres` executable could not be found on your system.
For help setting up your Postgres environment please follow the instructions for you platform at:

https://www.postgresql.org/download/

-> MySQL: Checking installation
✘ The `mysql` executable could not be found on your system.
For help setting up your MySQL environment please follow the instructions for you platform at:

https://www.mysql.com/downloads/

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.27.2, meets the minimum requirements.

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /go/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.15.3, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /go/src
Root        /go/src
GoPath      /go
PackagePkg  src
ActionsPkg  src/actions
ModelsPkg   src/models
GriftsPkg   src/grifts
WithModules false
Name        src
Bin         bin/src
VCS
WithPop     false
WithSQLite  false
WithDep     false
WithWebpack false
WithNodeJs  false
WithYarn    false
WithDocker  false
WithGrifts  false
AsWeb       true
AsAPI       false
InApp       false
PackageJSON {map[]}

Workaround

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:

buffalo plugins install

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.