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
|
||||
VERSION=`git describe --tags`
|
||||
|
||||
.PHONY: build
|
||||
## build: Compile the packages.
|
||||
# used for changing the output directory within docker containers
|
||||
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:
|
||||
@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
|
||||
## grunt: Compile frontend assets.
|
||||
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/*
|
||||
run:
|
||||
$(BUILD_DIR)/$(NAME)
|
||||
|
||||
.PHONY: 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:
|
||||
Reference in New Issue
Block a user