Skip to content

Commit d580fdf

Browse files
authored
Switch postgres image (#4)
* Allow specifying introspector ref and skipping image pull. Useful for local development * Switch to smaller official postgres image
1 parent 8741a83 commit d580fdf

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ func serviceSpec(r resourceSpecMap) string {
176176
func main() {
177177
pkger.Include("/templates")
178178
pkger.Include("/queries")
179-
var skipIntrospector, leavePostgresUp, reusePostgres, logIntrospector, printToStdOut bool
180-
var outputDir string
179+
var skipIntrospector, leavePostgresUp, reusePostgres, logIntrospector, printToStdOut, skipIntrospectorPull bool
180+
var outputDir, introspectorRef string
181181
flag.BoolVar(&skipIntrospector, "skip-introspector", false, "Skip running an import, use existing data")
182+
flag.BoolVar(&skipIntrospectorPull, "skip-introspector-pull", false, "Skip pulling the introspector docker image. Allows for using a local image")
183+
flag.StringVar(&introspectorRef, "introspector-ref", "", "Override the introspector docker image to use")
182184
flag.BoolVar(&leavePostgresUp, "leave-postgres", false, "Leave postgres running in a docker container")
183185
flag.BoolVar(&reusePostgres, "reuse-postgres", false, "Reuse an existing postgres instance, if it is running")
184186
flag.BoolVar(&logIntrospector, "log-introspector", false, "Pass through logs from introspector docker image")
@@ -210,7 +212,11 @@ func main() {
210212
if err != nil {
211213
panic(err)
212214
}
213-
i, err := introspector.New(ds, postgresService, introspector.Options{LogDockerOutput: logIntrospector})
215+
i, err := introspector.New(ds, postgresService, introspector.Options{
216+
LogDockerOutput: logIntrospector,
217+
SkipDockerPull: skipIntrospectorPull,
218+
InspectorRef: introspectorRef,
219+
})
214220
if err != nil {
215221
panic(err)
216222
}

pkg/introspector/introspector.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,24 @@ type Service struct {
2727

2828
type Options struct {
2929
LogDockerOutput bool
30+
SkipDockerPull bool
31+
InspectorRef string
32+
}
33+
34+
func (o *Options) fillInDefaults() {
35+
if o.InspectorRef == "" {
36+
o.InspectorRef = introspectorRef
37+
}
3038
}
3139

3240
func New(s *ds.Session, postgresService ps.PostgresService, opts Options) (*Service, error) {
3341
log.Info("Checking for introspector image")
34-
err := s.RequireImage(introspectorRef)
35-
if err != nil {
36-
return nil, errors.Wrap(err, "Failed to get instrospector docker image")
42+
opts.fillInDefaults()
43+
if !opts.SkipDockerPull {
44+
err := s.RequireImage(opts.InspectorRef)
45+
if err != nil {
46+
return nil, errors.Wrap(err, "Failed to get instrospector docker image")
47+
}
3748
}
3849
service, err := createIntrospectorContainer(s, postgresService, opts)
3950
if err != nil {
@@ -77,7 +88,7 @@ func createIntrospectorContainer(s *ds.Session, postgresService ps.PostgresServi
7788
fmt.Sprintf("INTROSPECTOR_DB_PORT=%v", address.HostPort),
7889
}
7990
containerBody, err := s.Client.ContainerCreate(s.Ctx, &container.Config{
80-
Image: introspectorRef,
91+
Image: opts.InspectorRef,
8192
Env: envVars,
8293
}, &container.HostConfig{
8394
NetworkMode: "host",

pkg/postgres/postgres.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func (dps *DockerPostgresService) Address() nat.PortBinding {
6161
}
6262

6363
const postgresContainerName = "postgres-db"
64-
const defaultPostgresRef = "supabase/postgres:0.13.0"
64+
65+
const defaultPostgresRef = "postgres:13-alpine"
6566
const defaultPostgresPort = 5432
6667

6768
func (o *DockerPostgresOptions) fillInDefaults() {

0 commit comments

Comments
 (0)