Initial structure
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -0,0 +1,13 @@
|
||||
FROM golang:1.24-alpine AS builder
|
||||
RUN apk update && apk add --no-cache git && apk add -U --no-cache ca-certificates
|
||||
WORKDIR /app/
|
||||
ADD go.mod go.sum ./
|
||||
RUN go mod download
|
||||
ADD . .
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o next-book .
|
||||
|
||||
FROM scratch
|
||||
WORKDIR /app/
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /app/next-book /app/next-book
|
||||
ENTRYPOINT ["/app/next-book"]
|
||||
|
||||
34
Makefile
34
Makefile
@@ -7,43 +7,27 @@ test: lint check-format run-tests
|
||||
|
||||
.PHONY: lint # Perform lint checks against code
|
||||
lint:
|
||||
@echo "⚠️ 'lint' unimplemented"
|
||||
# GO Projects
|
||||
# @go vet && golint -set_exit_status ./...
|
||||
@go vet && golint -set_exit_status ./...
|
||||
|
||||
.PHONY: check-format # Checks code formatting and returns a non-zero exit code if formatting errors found
|
||||
check-format:
|
||||
@echo "⚠️ 'check-format' unimplemented"
|
||||
# GO Projects
|
||||
# @gofmt -e -l .
|
||||
@gofmt -e -l .
|
||||
|
||||
.PHONY: format # Performs automatic format fixes on all code
|
||||
format:
|
||||
@echo "⚠️ 'format' unimplemented"
|
||||
# GO Projects
|
||||
# @gofmt -s -w .
|
||||
@gofmt -s -w .
|
||||
|
||||
.PHONY: run-tests # Runs all tests
|
||||
run-tests:
|
||||
@echo "⚠️ 'run-tests' unimplemented"
|
||||
# GO Projects
|
||||
# @go test
|
||||
# Node Projects
|
||||
# @npm test
|
||||
@go test
|
||||
|
||||
.PHONY: fetch-deps # Fetch all project dependencies
|
||||
fetch-deps:
|
||||
@echo "⚠️ 'fetch-deps' unimplemented"
|
||||
# GO Projects
|
||||
# @go mod tidy
|
||||
# Node Projects
|
||||
# @npm install
|
||||
@go mod tidy
|
||||
|
||||
.PHONY: build # Build the project
|
||||
build: lint check-format fetch-deps
|
||||
@echo "⚠️ 'build' unimplemented"
|
||||
# GO Projects
|
||||
# @go build -o PROJECT_NAME main.go
|
||||
@go build -o PROJECT_NAME main.go
|
||||
|
||||
.PHONY: docker-build # Build the docker image
|
||||
docker-build:
|
||||
@@ -55,11 +39,7 @@ docker-publish:
|
||||
|
||||
.PHONY: run # Run the application
|
||||
run:
|
||||
@echo "⚠️ 'run' unimplemented"
|
||||
# GO Projects
|
||||
# @go run main.go
|
||||
# Node Projects
|
||||
# @npm start
|
||||
@go run main.go
|
||||
|
||||
.PHONY: ci # Perform CI specific tasks to perform on a pull request
|
||||
ci:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# next-book
|
||||
|
||||
|
||||
Checks the users Storygraph "to read" list and shows the highest rated in various catergories.
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
5
go.mod
Normal file
5
go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module nextbook
|
||||
|
||||
go 1.24.0
|
||||
|
||||
require github.com/joho/godotenv v1.5.1
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
38
main.go
Normal file
38
main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var (
|
||||
port string
|
||||
)
|
||||
|
||||
func init() {
|
||||
godotenv.Load(os.Getenv("DOTENV_DIR") + ".env")
|
||||
|
||||
var ok bool
|
||||
port, ok = os.LookupEnv("PORT")
|
||||
if !ok {
|
||||
port = "8000"
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
go updateWorker()
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
})
|
||||
|
||||
http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
|
||||
}
|
||||
|
||||
func updateWorker() {
|
||||
// TODO: Update worker
|
||||
}
|
||||
Reference in New Issue
Block a user