9494endif
9595endif
9696
97+ # # Alias for server target - builds the server component.
98+ .PHONY : build
99+ build : server
100+
97101# # Ensures NPM dependencies are installed without having to run this all the time.
98102webapp/node_modules : $(wildcard webapp/package.json)
99103ifneq ($(HAS_WEBAPP ) ,)
@@ -279,6 +283,24 @@ ifneq ($(HAS_WEBAPP),)
279283endif
280284 rm -fr build/bin/
281285
286+ # # Formats Go and Markdown code.
287+ .PHONY : format
288+ format :
289+ @echo Formatting code...
290+ ifneq ($(HAS_SERVER ) ,)
291+ @echo Formatting Go files...
292+ $(GO) fmt ./...
293+ endif
294+ @echo Formatting Markdown files...
295+ @if command -v prettier > /dev/null 2>&1; then \
296+ prettier --write "**/*.md"; \
297+ elif command -v npx > /dev/null 2>&1; then \
298+ npx --yes prettier --write "**/*.md"; \
299+ else \
300+ echo "Warning: prettier not found. Install it with 'npm install -g prettier' to format Markdown files."; \
301+ fi
302+ @echo Formatting complete.
303+
282304.PHONY : logs
283305logs :
284306 ./build/bin/pluginctl logs $(PLUGIN_ID )
@@ -287,23 +309,40 @@ logs:
287309logs-watch :
288310 ./build/bin/pluginctl logs-watch $(PLUGIN_ID )
289311
290- # Development environment management with Docker Compose
291- DOCKER_COMPOSE_FILE ?= docker -compose.yml
292- DOCKER_COMPOSE := docker -compose -f $(DOCKER_COMPOSE_FILE )
312+ # Development environment management with Podman Compose
313+ PODMAN_COMPOSE_FILE ?= podman -compose.yml
314+ PODMAN_COMPOSE := podman -compose -f $(PODMAN_COMPOSE_FILE )
293315
294- # # Starts the Docker Compose development stack.
316+ # # Sets up the required directories for Podman development stack.
317+ .PHONY : dev-setup
318+ dev-setup :
319+ @echo " Setting up development environment directories..."
320+ @mkdir -p podman/data/mattermost/plugins podman/data/mattermost/client/plugins podman/data/postgres podman/config
321+ @chmod -R 777 podman/config podman/data/mattermost 2> /dev/null || true
322+ @echo " Directories created and permissions set."
323+
324+ # # Starts the Podman Compose development stack.
295325.PHONY : dev-up
296- dev-up :
326+ dev-up : dev-setup
297327 @echo " Starting development environment..."
298- $(DOCKER_COMPOSE ) up -d
328+ $(PODMAN_COMPOSE ) up -d
299329 @echo " Waiting for Mattermost to be ready..."
300330 @timeout 60 bash -c ' until $$(curl -s http://localhost:8065/api/v4/system/ping > /dev/null 2>&1); do sleep 2; done' || echo " Mattermost is starting. Access at http://localhost:8065"
331+ @echo " Creating admin account if it doesn't exist..."
332+ @$(MAKE ) dev-create-admin || echo " Admin account already exists or creation failed"
301333
302- # # Stops the Docker Compose development stack.
334+ # # Stops the Podman Compose development stack.
303335.PHONY : dev-down
304336dev-down :
305337 @echo " Stopping development environment..."
306- $(DOCKER_COMPOSE ) down
338+ $(PODMAN_COMPOSE ) down
339+
340+ # # Creates the admin account if it doesn't exist.
341+ # # Uses credentials from podman-compose.yml (admin/admin123/[email protected] )342+ # # Also creates a default team and adds the admin user to it.
343+ .PHONY : dev-create-admin
344+ dev-create-admin :
345+ @./scripts/dev-create-admin.sh
307346
308347# # Alias for dev-up
309348.PHONY : dev-start
@@ -313,123 +352,88 @@ dev-start: dev-up
313352.PHONY : dev-stop
314353dev-stop : dev-down
315354
316- # # Restarts the Docker Compose development stack.
355+ # # Restarts the Podman Compose development stack.
317356.PHONY : dev-restart
318357dev-restart : dev-down dev-up
319358
320359# # Removes containers, volumes, and data for a clean start.
321360.PHONY : dev-clean
322361dev-clean :
323362 @echo " Cleaning development environment (removing containers, volumes, and data)..."
324- $(DOCKER_COMPOSE ) down -v
325- rm -rf docker /data/* docker /config/*
363+ $(PODMAN_COMPOSE ) down -v
364+ sudo rm -rf podman /data/* podman /config/*
326365 @echo " Development environment cleaned. Run 'make dev-up' to start fresh."
327366
328367# # Views Mattermost server logs.
329368.PHONY : dev-logs
330369dev-logs :
331- $(DOCKER_COMPOSE ) logs mattermost
370+ $(PODMAN_COMPOSE ) logs mattermost
332371
333372# # Tails Mattermost server logs in real-time.
334373.PHONY : dev-logs-watch
335374dev-logs-watch :
336- $(DOCKER_COMPOSE ) logs -f mattermost
375+ $(PODMAN_COMPOSE ) logs -f mattermost
337376
338- # # Builds and deploys the plugin to the Docker development stack.
377+ # # Builds and deploys the plugin to the Podman development stack.
339378.PHONY : dev-deploy
340379dev-deploy : dist
341- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
342- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
343- exit 1; \
344- fi
345- @echo " Deploying plugin to development environment..."
346- @if [ -f docker/.env ]; then \
347- echo " Loading environment variables from docker/.env..." ; \
348- set -a && . docker/.env && set +a; \
349- fi
350- @if [ -z " $$ MM_ADMIN_TOKEN" ] && [ -z " $$ MM_ADMIN_USERNAME" ]; then \
351- echo " Warning: MM_ADMIN_TOKEN or MM_ADMIN_USERNAME/MM_ADMIN_PASSWORD not set." ; \
352- echo " Please set them in docker/.env or export them in your shell." ; \
353- echo " See docker/env.example for an example." ; \
354- fi
355- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
356- ./build/bin/pluginctl deploy $(PLUGIN_ID ) dist/$(BUNDLE_NAME )
357- @echo " Plugin deployed. Run 'make dev-enable' to enable it, or enable via System Console."
380+ @PLUGIN_ID=$(PLUGIN_ID ) BUNDLE_NAME=dist/$(BUNDLE_NAME ) ./scripts/dev-deploy.sh
358381
359382# # Opens a shell in the Mattermost container.
360383.PHONY : dev-shell
361384dev-shell :
362- $(DOCKER_COMPOSE ) exec mattermost /bin/sh
385+ $(PODMAN_COMPOSE ) exec mattermost /bin/sh
363386
364- # # Shows status of Docker Compose services.
387+ # # Shows status of Podman Compose services.
365388.PHONY : dev-status
366389dev-status :
367- $(DOCKER_COMPOSE ) ps
390+ $(PODMAN_COMPOSE ) ps
368391
369392# # Enables the plugin in the development environment.
370393.PHONY : dev-enable
371394dev-enable :
372- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
373- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
374- exit 1; \
375- fi
376- @if [ -f docker/.env ]; then \
377- set -a && . docker/.env && set +a; \
378- fi
379- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
395+ @./scripts/dev-check-container.sh
396+ @MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
380397 ./build/bin/pluginctl enable $(PLUGIN_ID )
381398
382399# # Disables the plugin in the development environment.
383400.PHONY : dev-disable
384401dev-disable :
385- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
386- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
387- exit 1; \
388- fi
389- @if [ -f docker/.env ]; then \
390- set -a && . docker/.env && set +a; \
391- fi
392- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
402+ @./scripts/dev-check-container.sh
403+ @MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
393404 ./build/bin/pluginctl disable $(PLUGIN_ID )
394405
395406# # Resets the plugin in the development environment (disables and re-enables).
396407.PHONY : dev-reset
397408dev-reset :
398- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
399- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
400- exit 1; \
401- fi
402- @if [ -f docker/.env ]; then \
403- set -a && . docker/.env && set +a; \
404- fi
405- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
409+ @./scripts/dev-check-container.sh
410+ @MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
406411 ./build/bin/pluginctl reset $(PLUGIN_ID )
407412
408413# # Views plugin logs in the development environment.
409414.PHONY : dev-plugin-logs
410415dev-plugin-logs :
411- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
412- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
413- exit 1; \
414- fi
415- @if [ -f docker/.env ]; then \
416- set -a && . docker/.env && set +a; \
417- fi
418- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
416+ @./scripts/dev-check-container.sh
417+ @MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
419418 ./build/bin/pluginctl logs $(PLUGIN_ID )
420419
421420# # Tails plugin logs in the development environment.
422421.PHONY : dev-plugin-logs-watch
423422dev-plugin-logs-watch :
424- @if ! $(DOCKER_COMPOSE ) ps mattermost | grep -q " Up" ; then \
425- echo " Error: Mattermost container is not running. Run 'make dev-up' first." ; \
423+ @./scripts/dev-check-container.sh
424+ @MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
425+ ./build/bin/pluginctl logs-watch $(PLUGIN_ID )
426+
427+ # # Pings the Mattermost healthcheck endpoint to verify server is responding.
428+ .PHONY : dev-check-ping
429+ dev-check-ping :
430+ @echo " Checking Mattermost healthcheck endpoint..."
431+ @if $(CURL ) -f -s http://localhost:8065/api/v4/system/ping > /dev/null 2>&1 ; then \
432+ echo " ✓ Mattermost is responding (http://localhost:8065/api/v4/system/ping)" ; \
433+ else \
434+ echo " ✗ Mattermost is not responding. Is it running? (Try 'make dev-up')" ; \
426435 exit 1; \
427436 fi
428- @if [ -f docker/.env ]; then \
429- set -a && . docker/.env && set +a; \
430- fi
431- MM_SERVICESETTINGS_SITEURL=http://localhost:8065 \
432- ./build/bin/pluginctl logs-watch $(PLUGIN_ID )
433437
434438# Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
435439help :
0 commit comments