File tree Expand file tree Collapse file tree 4 files changed +11
-9
lines changed
Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ COPY . .
66
77RUN go build -ldflags="-s -w" -o rabbit.go main.go
88
9- FROM gcr.io/distroless/static-debian12:latest as runner
9+ FROM gcr.io/distroless/static-debian12:latest AS runner
1010
1111COPY --from=builder /app/rabbit.go /usr/local/bin/rabbit.go
12+ COPY --from=builder /app/internal/database/migrations.sql /usr/local/bin/internal/database/migrations.sql
1213
1314# 9999 is the tunnel server port
1415# 3422 is the API port (never expose this port to the internet)
Original file line number Diff line number Diff line change @@ -23,9 +23,10 @@ var databaseCmd = &cobra.Command{
2323}
2424
2525var migrateCmd = & cobra.Command {
26- Use : "migrate" ,
26+ Use : "migrate <path> " ,
2727 Short : "Run database migrations" ,
2828 Long : `Create database tables and run migrations.` ,
29+ Args : cobra .ExactArgs (1 ),
2930 RunE : func (cmd * cobra.Command , args []string ) error {
3031 config := database .GetConfigFromEnv ()
3132 db , err := database .NewDatabase (config )
@@ -42,7 +43,7 @@ var migrateCmd = &cobra.Command{
4243 // return fmt.Errorf("failed to clean up database: %w", err)
4344 // }
4445
45- if err := db .RunMigrations (); err != nil {
46+ if err := db .RunMigrations (args [ 0 ] ); err != nil {
4647 return fmt .Errorf ("migration failed: %w" , err )
4748 }
4849
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ services:
99 - " 9999:9999"
1010 - " 3422:3422"
1111 env_file :
12- - .env
12+ - ./. env
1313 depends_on :
1414 rabbit-migrate :
1515 condition : service_completed_successfully
@@ -21,14 +21,14 @@ services:
2121 build :
2222 context : .
2323 dockerfile : Dockerfile
24- command : /usr/local/bin/rabbit.go database migrate
24+ command : /usr/local/bin/rabbit.go database migrate /usr/local/bin/internal/database/migrations.sql
2525 env_file :
26- - .env
26+ - ./. env
2727 networks :
2828 # optional, if you want to use dokploy network
2929 - dokploy-network
3030
3131networks :
3232 # optional, if you want to use dokploy network
3333 dokploy-network :
34- external : true
34+ driver : bridge
Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ func (d *Database) CleanUp() error {
105105}
106106
107107// RunMigrations runs the database migrations
108- func (d * Database ) RunMigrations () error {
109- migrationFile := "internal/database/migrations.sql"
108+ func (d * Database ) RunMigrations (path string ) error {
109+ migrationFile := path
110110
111111 // Read migration file
112112 migrationSQL , err := os .ReadFile (migrationFile )
You can’t perform that action at this time.
0 commit comments