Skip to content

Commit

Permalink
add some logs and update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Cijin committed Oct 12, 2024
1 parent dccdec8 commit f3ad529
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:18 AS tailwind-builder
FROM node:20 AS tailwind-builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build-css

FROM golang:1.23 AS go-builder
FROM golang:1.23.2-bookworm AS go-builder
WORKDIR /app
COPY . .

Expand All @@ -23,7 +23,8 @@ WORKDIR /app
COPY --from=tailwind-builder /app/public ./public
COPY --from=go-builder /app/server .
COPY --from=go-builder /app/migration .
COPY --from=go-builder /app/scripts/start.sh .

EXPOSE 8080
RUN chmod +x start.sh

ENTRYPOINT ["/bin/sh", "-c", "./migration && ./server"]
ENTRYPOINT ["start.sh"]
10 changes: 5 additions & 5 deletions cmd/migration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ import (
_ "github.com/tursodatabase/go-libsql"
)

const command = "up"

//go:embed migrations/*.sql
var embedMigrations embed.FS

func main() {
sqlURL := os.Getenv("SQL_URL")
if sqlURL == "" {
dbURL := os.Getenv("SQL_URL")
if dbURL == "" {
log.Fatal("No SQL_URL set in env")
}

db, err := sql.Open("libsql", sqlURL)
db, err := sql.Open("libsql", dbURL)
if err != nil {
log.Fatal("error opening database: ", err)
}
Expand All @@ -39,4 +37,6 @@ func main() {
if err := goose.Up(db, "migrations"); err != nil {
log.Fatal(err)
}

log.Println("Migration run is complete")
}
3 changes: 3 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ primary_region = 'sin'

[build]

[env]
PORT = '8080'

[http_service]
internal_port = 8080
force_https = true
Expand Down
4 changes: 4 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e
./migration
exec ./server

0 comments on commit f3ad529

Please sign in to comment.