Skip to content

Commit

Permalink
Use C sqlite library for docker builds (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfontan authored Sep 19, 2021
1 parent 373aeef commit f6b1ecc
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apt-get update && \
WORKDIR /build
COPY . .

RUN go build -v ./server/cmd/glslsandbox
RUN go build -tags cgosqlite -v ./server/cmd/glslsandbox

FROM debian:buster-slim

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo/v4 v4.3.0
github.com/labstack/gommon v0.3.0
github.com/mattn/go-sqlite3 v1.14.7 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/stretchr/testify v1.7.0
github.com/uptrace/bun/driver/sqliteshim v1.0.8
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
modernc.org/sqlite v1.11.2
modernc.org/sqlite v1.11.2 // indirect
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/uptrace/bun/driver/sqliteshim v1.0.8 h1:7dO/3Wr5WyFdgvCZdIa6C0XUkP4WFg9Xr5DQLmXActk=
github.com/uptrace/bun/driver/sqliteshim v1.0.8/go.mod h1:c+qP5NHuMNtUAHYFGfs8OfKAq9nLshPQcUeU34KWzoI=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
Expand Down Expand Up @@ -124,6 +126,7 @@ modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.11.1/go.mod h1:+mhs/P1ONd+6G7hcAs6irwDi/bjTQ7nLW6LHRBsEa3A=
modernc.org/sqlite v1.11.2 h1:ShWQpeD3ag/bmx6TqidBlIWonWmQaSQKls3aenCbt+w=
modernc.org/sqlite v1.11.2/go.mod h1:+mhs/P1ONd+6G7hcAs6irwDi/bjTQ7nLW6LHRBsEa3A=
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
Expand Down
3 changes: 2 additions & 1 deletion server/cmd/glsladmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/jmoiron/sqlx"
"github.com/kelseyhightower/envconfig"
"github.com/mrdoob/glsl-sandbox/server/store"
"github.com/uptrace/bun/driver/sqliteshim"
"golang.org/x/crypto/bcrypt"
)

Expand Down Expand Up @@ -56,7 +57,7 @@ func start() error {
return fmt.Errorf("could not read environment config: %w", err)
}

db, err := sqlx.Open("sqlite", dbURL(cfg.DataPath))
db, err := sqlx.Open(sqliteshim.ShimName, dbURL(cfg.DataPath))
if err != nil {
return fmt.Errorf("could not open database: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion server/cmd/glslsandbox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kelseyhightower/envconfig"
"github.com/mrdoob/glsl-sandbox/server"
"github.com/mrdoob/glsl-sandbox/server/store"
"github.com/uptrace/bun/driver/sqliteshim"
)

const dbName = "glslsandbox.db"
Expand Down Expand Up @@ -45,7 +46,7 @@ func start() error {
return fmt.Errorf("could not create data directory: %w", err)
}

db, err := sqlx.Open("sqlite", dbURL(cfg.DataPath))
db, err := sqlx.Open(sqliteshim.ShimName, dbURL(cfg.DataPath))
if err != nil {
return fmt.Errorf("could not open database: %w", err)
}
Expand Down
2 changes: 0 additions & 2 deletions server/store/effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"

"github.com/jmoiron/sqlx"

_ "modernc.org/sqlite"
)

type Effect struct {
Expand Down
3 changes: 2 additions & 1 deletion server/store/effects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/jmoiron/sqlx"
"github.com/stretchr/testify/require"
"github.com/uptrace/bun/driver/sqliteshim"
)

type helper struct {
Expand All @@ -26,7 +27,7 @@ var tests = []helper{
func TestEffects(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
db, err := sqlx.Open("sqlite", testDatabase)
db, err := sqlx.Open(sqliteshim.ShimName, testDatabase)
require.NoError(t, err)

s, err := NewEffects(db)
Expand Down
9 changes: 5 additions & 4 deletions server/store/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/jmoiron/sqlx"
"github.com/stretchr/testify/require"
"github.com/uptrace/bun/driver/sqliteshim"
)

var (
Expand All @@ -23,7 +24,7 @@ var (
)

func TestUserAdd(t *testing.T) {
db, err := sqlx.Connect("sqlite", testDatabase)
db, err := sqlx.Connect(sqliteshim.ShimName, testDatabase)
require.NoError(t, err)

users, err := NewUsers(db)
Expand All @@ -45,7 +46,7 @@ func TestUserAdd(t *testing.T) {
}

func TestUserUpdate(t *testing.T) {
db, err := sqlx.Connect("sqlite", testDatabase)
db, err := sqlx.Connect(sqliteshim.ShimName, testDatabase)
require.NoError(t, err)

users, err := NewUsers(db)
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestUserUpdate(t *testing.T) {
}

func TestUserUpdateFunc(t *testing.T) {
db, err := sqlx.Connect("sqlite", testDatabase)
db, err := sqlx.Connect(sqliteshim.ShimName, testDatabase)
require.NoError(t, err)

users, err := NewUsers(db)
Expand Down Expand Up @@ -120,7 +121,7 @@ func TestUserUpdateFunc(t *testing.T) {
}

func TestUserGetAll(t *testing.T) {
db, err := sqlx.Connect("sqlite", testDatabase)
db, err := sqlx.Connect(sqliteshim.ShimName, testDatabase)
require.NoError(t, err)

users, err := NewUsers(db)
Expand Down

0 comments on commit f6b1ecc

Please sign in to comment.