Added Docker container and compose definitions to make development easier
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
FROM golang:1.26
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt install -y make gcc
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
|
|
||||||
|
# Copy dependency definitions first (caching optimization)
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN make build BUILD_DIR=/tmp
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Node.js runtime
|
||||||
|
FROM node:24
|
||||||
|
|
||||||
|
WORKDIR /var/www/html/
|
||||||
|
|
||||||
|
COPY package.* /var/www/html/
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Run the app
|
||||||
|
CMD [ "npm", "run", "grunt" ]
|
||||||
@@ -1,45 +1,24 @@
|
|||||||
NAME=blt
|
NAME=blt
|
||||||
VERSION=`git describe --tags`
|
VERSION=`git describe --tags`
|
||||||
|
|
||||||
.PHONY: build
|
# used for changing the output directory within docker containers
|
||||||
## build: Compile the packages.
|
BUILD_DIR ?= .
|
||||||
|
|
||||||
|
dev-up:
|
||||||
|
docker compose -f docker-dev.yml up -d
|
||||||
|
|
||||||
|
dev-down:
|
||||||
|
docker compose -f docker-dev.yml down
|
||||||
|
|
||||||
|
dev-build:
|
||||||
|
docker compose -f docker-dev.yml build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
|
@echo "Building Go binary..."
|
||||||
|
@go build -o $(BUILD_DIR)/$(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
|
||||||
|
|
||||||
.PHONY: grunt
|
run:
|
||||||
## grunt: Compile frontend assets.
|
$(BUILD_DIR)/$(NAME)
|
||||||
grunt:
|
|
||||||
@npm run grunt
|
|
||||||
|
|
||||||
.PHONY: grunt-watch
|
|
||||||
## grunt-watch: Compile frontend assets while watching for changes.
|
|
||||||
grunt-watch:
|
|
||||||
@npm run grunt watch
|
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
## run: Build and Run in development mode.
|
|
||||||
run: build
|
|
||||||
@./$(NAME) -e development
|
|
||||||
|
|
||||||
.PHONY: run-prod
|
|
||||||
## run-prod: Build and Run in production mode.
|
|
||||||
run-prod: build
|
|
||||||
@./$(NAME) -e production
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
## clean: Clean project and previous builds.
|
|
||||||
clean:
|
|
||||||
@rm -f $(NAME)
|
|
||||||
|
|
||||||
.PHONY: deps
|
|
||||||
## deps: Download modules
|
|
||||||
deps:
|
|
||||||
@go mod download
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
## test: Run tests with verbose mode
|
|
||||||
test:
|
|
||||||
@go test -v ./tests/*
|
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
all: help
|
all: help
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
command: make run BUILD_DIR=/tmp
|
||||||
|
ports:
|
||||||
|
- "2830:2830"
|
||||||
|
volumes:
|
||||||
|
- .:/app # Mounts local directory for hot-reloading/live edits
|
||||||
|
- go-modules:/go/pkg/mod # Caches Go modules on host
|
||||||
|
# Mount the compiled static assets generated by Grunt
|
||||||
|
- static-assets:/app/public
|
||||||
|
environment:
|
||||||
|
- APP_ENV=development
|
||||||
|
assets:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.grunt
|
||||||
|
# Override CMD to run watch mode during local dev
|
||||||
|
command: npm run grunt watch
|
||||||
|
volumes:
|
||||||
|
# Mount host code so Grunt detects file changes in real time
|
||||||
|
- .:/var/www/html
|
||||||
|
# Preserve container node_modules from being overwritten by host
|
||||||
|
- /var/www/html/node_modules
|
||||||
|
# Output compiled assets into the shared volume
|
||||||
|
- static-assets:/var/www/html/public
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
go-modules:
|
||||||
|
static-assets:
|
||||||
@@ -44,6 +44,6 @@ func main() {
|
|||||||
web.RegisterRoutes(f)
|
web.RegisterRoutes(f)
|
||||||
|
|
||||||
// alert the user and start the server
|
// alert the user and start the server
|
||||||
log.Println("Server is running...")
|
log.Println("Server is listening on 0.0.0.0:2830.")
|
||||||
log.Println(http.ListenAndServe("0.0.0.0:2830", f))
|
log.Println(http.ListenAndServe("0.0.0.0:2830", f))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user