chore: improve container build and deployment configuration

- Add common system directories to .dockerignore to prevent accidental inclusion
- Reorder Dockerfile instructions for better clarity and performance
- Remove remote deployment targets from Makefile to simplify local development workflow
This commit is contained in:
Jp
2026-02-26 13:44:36 +08:00
parent a4124ceaa9
commit 1dbc32722a
3 changed files with 18 additions and 23 deletions

View File

@@ -19,3 +19,15 @@ Dockerfile
.dockerignore
Makefile
k8s/
/mounts
/proc
/sys
/dev
/run
/var/lib/containers
/mnt
/media
/boot
/lost+found
/root
/srv

View File

@@ -22,11 +22,12 @@ RUN apk add --no-cache \
# Create a symlink so 'php' command works
RUN ln -sf /usr/bin/php84 /usr/bin/php
# Copy application files
# Using a different target directory to avoid permission issues with /var/www in Alpine/Podman
COPY . /app
# Set working directory early
WORKDIR /app
# Copy application files explicitly from the context
COPY . /app
# Get Composer
COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer

View File

@@ -3,11 +3,6 @@ IMG := mkm-admin
build:
podman build -t $(IMG) .
# Server configuration (Change these to your actual server details)
SERVER_USER := ubuntu
SERVER_IP := 192.168.100.200
SERVER_PATH := /var/www/MKM
deploy: build
@echo "Cleaning up existing deployment if any..."
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
@@ -17,22 +12,9 @@ deploy: build
@cat k8s/deployment.yaml >> /tmp/merged_deployment.yaml
@echo "Deploying via podman kube play..."
podman kube play /tmp/merged_deployment.yaml
@rm /tmp/merged_deployment.yaml
deploy-server:
@echo "Deploying to remote server $(SERVER_IP)..."
@# Build image on the remote server
ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && sudo podman build --no-cache -t $(IMG) ."
@# Generate temporary merged YAML for server in /tmp
@sudo kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > /tmp/server_deploy.yaml
@echo "---" >> /tmp/server_deploy.yaml
@cat k8s/deployment.yaml >> /tmp/server_deploy.yaml
@# Single SCP/SSH call to apply
scp /tmp/server_deploy.yaml $(SERVER_USER)@$(SERVER_IP):/tmp/server_deploy.yaml
ssh $(SERVER_USER)@$(SERVER_IP) "sudo kubectl apply -f /tmp/server_deploy.yaml && rm -f /tmp/server_deploy.yaml"
@rm -f /tmp/server_deploy.yaml
@rm -f /tmp/merged_deployment.yaml
stop:
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
.PHONY: build deploy deploy-server stop
.PHONY: build deploy stop