diff --git a/Justfile b/Justfile index 90fabf6..cb905e4 100644 --- a/Justfile +++ b/Justfile @@ -23,13 +23,10 @@ load-release file: # Tests every part of the project testall: - cd frontend && npm install cd frontend && npm test cd frontend && npm run lint - cd frontend && npm run build cd backend && make test cd backend && make lint - cd backend && make itest # Cleans up everything related to the project clean: remove-podman-containers diff --git a/Makefile b/Makefile index 51fb206..97db62e 100644 --- a/Makefile +++ b/Makefile @@ -13,13 +13,10 @@ remove-podman-containers: # Tests every part of the project testall: - cd frontend && npm install cd frontend && npm test cd frontend && npm run lint - cd frontend && npm run build cd backend && make test cd backend && make lint - cd backend && make itest # Cleans up everything related to the project clean: remove-podman-containers diff --git a/backend/Makefile b/backend/Makefile index 3443e94..331f8d5 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -8,19 +8,17 @@ GOGET = $(GOCMD) get # SQLite database filename DB_FILE = db.sqlite3 -PROC_NAME = ttime_server - # Directory containing migration SQL scripts MIGRATIONS_DIR = internal/database/migrations SAMPLE_DATA_DIR = internal/database/sample_data # Build target build: - $(GOBUILD) -o bin/$(PROC_NAME) main.go + $(GOBUILD) -o bin/server main.go # Run target run: build - ./bin/$(PROC_NAME) + ./bin/server watch: build watchexec -c -w . -r make run @@ -39,16 +37,6 @@ clean: test: db.sqlite3 $(GOTEST) ./... -count=1 -# Integration test target -.PHONY: itest -itest: - pgrep $(PROC_NAME) && echo "Server already running" && exit 1 || true - make build - ./bin/$(PROC_NAME) >/dev/null 2>&1 & - sleep 1 # Adjust if needed - python ../testing.py - pkill $(PROC_NAME) - # Get dependencies target deps: $(GOGET) -v ./... diff --git a/container/Containerfile b/container/Containerfile index f9cb39d..ecd2f84 100644 --- a/container/Containerfile +++ b/container/Containerfile @@ -13,6 +13,7 @@ FROM docker.io/golang:alpine as go RUN apk add gcompat RUN apk add gcc RUN apk add musl-dev +RUN apk add make RUN apk add sqlite WORKDIR /build ADD backend/go.mod backend/go.sum ./ @@ -23,7 +24,9 @@ RUN go mod download # Add the source code ADD backend . -RUN go build -o server +RUN make migrate + +# RUN go build -o server RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./main.go # Strip the binary for a smaller image @@ -34,7 +37,6 @@ FROM docker.io/alpine:latest as runner RUN adduser -D nonroot RUN addgroup nonroot nonroot WORKDIR /app -RUN chown nonroot:nonroot /app # Copy the frontend SPA build into public COPY --from=client /build/dist static @@ -42,6 +44,9 @@ COPY --from=client /build/dist static # Copy the server binary COPY --from=go /build/server server +# Copy the database +COPY --from=go /build/db.sqlite3 db.sqlite3 + # Expose port 8080 EXPOSE 8080 diff --git a/frontend/src/Components/NewWeeklyReport.tsx b/frontend/src/Components/NewWeeklyReport.tsx index a128b8d..292ddf5 100644 --- a/frontend/src/Components/NewWeeklyReport.tsx +++ b/frontend/src/Components/NewWeeklyReport.tsx @@ -60,7 +60,8 @@ export default function NewWeeklyReport(): JSX.Element { type="week" placeholder="Week" onChange={(e) => { - setWeek(parseInt(e.target.value)); + const weekNumber = parseInt(e.target.value.split("-W")[1]); + setWeek(weekNumber); }} onKeyDown={(event) => { const keyValue = event.key;