Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Taskfile support #28

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
templates/**/* linguist-vendored
public/**/*.css linguist-vendored
*.sh text eol=lf
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all install build_frontend build_backend build build_docker watch_frontend watch_backend watch clean clean_docker

# Specify the name of your Go binary output
# Specify the name of your Go binary output or Docker image
BINARY_NAME := opengist

all: install build
Expand Down
84 changes: 84 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# https://taskfile.dev

version: '3'

vars:
# Specify the name of your Go binary output or Docker image
BINARY_NAME: opengist

# Prevent the full commands from being logged (https://taskfile.dev/usage/#silent-mode)
silent: true

tasks:
default:
desc: List available tasks. Same as running `task` without arguments
cmds:
- task --list-all

all:
desc: Install dependencies and build
cmds:
- task: install
- task: build

install:
desc: Install NPM and Go dependencies
cmds:
- echo "Installing NPM dependencies..."
- 'npm ci || (echo "Error: Failed to install NPM dependencies." && exit 1)'
- echo "Installing Go dependencies..."
- 'go mod download || (echo "Error: Failed to install Go dependencies." && exit 1)'

build_frontend:
desc: Build the frontend assets
cmds:
- echo "Building frontend assets..."
- ./node_modules/.bin/vite build

build_backend:
desc: Build the backend binary
cmds:
- echo "Building Opengist binary..."
- go build -tags fs_embed -o {{.BINARY_NAME}} .

build:
desc: Build both the frontend and backend
cmds:
- task: build_frontend
- task: build_backend

build_docker:
desc: Build Docker image
cmds:
- echo "Building Docker image..."
- docker build -t {{.BINARY_NAME}}:latest .

watch_frontend:
desc: Start frontend in dev mode, watching for changes
cmds:
- echo "Building frontend assets..."
- ./node_modules/.bin/vite dev --port 16157

watch_backend:
desc: Start backend and watch for changes
cmds:
- echo "Building Opengist binary..."
- DEV=1 ./node_modules/.bin/nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'

watch:
desc: Starts both frontend and backend, watching for changes
cmds:
- task -p watch_frontend watch_backend

clean:
desc: Clean up build artifacts
cmds:
- echo "Cleaning up build artifacts..."
- rm -f {{.BINARY_NAME}} public/manifest.json
- rm -rf public/assets

clean_docker:
desc: Remove Docker image
cmds:
- echo "Cleaning up Docker image..."
- docker rmi {{.BINARY_NAME}}
9 changes: 7 additions & 2 deletions watch.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash
set -euo pipefail

make watch_frontend &
make watch_backend &
if [ "$1" == "task" ]; then
task watch_frontend &
task watch_backend &
else
make watch_frontend &
make watch_backend &
fi

trap 'kill $(jobs -p)' EXIT
wait