Skip to content

Commit

Permalink
Merge pull request #33 from okdv/v1.1.0-alpha
Browse files Browse the repository at this point in the history
v1.1.0-alpha: Various bug fixes, example db
  • Loading branch information
okdv committed Apr 22, 2024
2 parents d006174 + f0e6a62 commit 4788e54
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
9 changes: 6 additions & 3 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# the frontend url, if using docker url should be host machine
PUBLIC_FRONTEND_URL=http://localhost:5173
# if running inside docker, this would be the containers port number
PUBLIC_FRONTEND_PORT=5173

# the api url called by frontend, if using docker url should be host machine
PUBLIC_API_URL=http://localhost:8080
# if running inside docker, this would be the containers port number
PUBLIC_API_PORT=8080

# should be production if running in prod
NODE_ENV=development

# CHANGE THIS
JWT_KEY=wrenchturn_secret_key

DB_FILENAME=sqlite.db
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ wrench-turn
*.so
*.dylib
tmp/
releases/

# Test binary, built with `go test -c`
*.test
Expand All @@ -27,4 +28,5 @@ go.work
./data

# databases
*.db
*.db
!example.db
11 changes: 6 additions & 5 deletions backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.5-alpine3.18 AS build
FROM golang:1.22.2-alpine3.19 AS build

ARG GO_ENV=production
ENV GO_ENV=production
Expand All @@ -7,19 +7,20 @@ RUN apk update && apk add --no-cache gcc musl-dev

WORKDIR /app

COPY go.* .
COPY go.* ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -o wrench-turn .
COPY . ./
RUN CGO_ENABLED=1 GOOS=linux go build -o wrench-turn ./

FROM alpine:latest

ARG GO_ENV=production
ENV GO_ENV=production

WORKDIR /app
COPY --from=build /app/wrench-turn .
COPY --from=build /app/wrench-turn ./
COPY --from=build /app/schema.sql ./

EXPOSE 8080
ENTRYPOINT ["./wrench-turn"]
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
context: .
dockerfile: backend.Dockerfile
volumes:
- ./sqlite.db:/app/sqlite.db
- ./data:/app/data
- ./.env.production:/app/.env.production
ports:
- 8080:8080
Expand Down
Binary file added example.db
Binary file not shown.
6 changes: 4 additions & 2 deletions frontend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ ENV NODE_ENV=production
WORKDIR /app

COPY ./frontend /app/
# Copy backend env to frontend for easier deployment
COPY ./.env.production ./

RUN npm ci
RUN npm run build

FROM nginx:1.25-alpine

WORKDIR /etc/nginx
COPY --from=build /app/nginx.conf .
COPY --from=build /app/nginx.conf ./

WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=build /app/build .
COPY --from=build /app/build ./

ENTRYPOINT ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ require (
github.com/go-chi/cors v1.2.1
github.com/golang-jwt/jwt/v5 v5.1.0
github.com/joho/godotenv v1.5.1
github.com/mattn/go-sqlite3 v1.14.17
github.com/mattn/go-sqlite3 v1.14.19
golang.org/x/crypto v0.22.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HW
github.com/golang-jwt/jwt/v5 v5.1.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
}

// check if db file exists
dbFilename := os.Getenv("DB_FILENAME")
dbFilename := "./data/" + os.Getenv("DB_FILENAME")
if _, err := os.Stat(dbFilename); os.IsNotExist(err) {
// if not, create it
log.Printf("database file %v does not exist, running db setup... ", dbFilename)
Expand Down

0 comments on commit 4788e54

Please sign in to comment.