31 Commits

Author SHA1 Message Date
Jp
993d096283 test 2026-02-26 14:02:41 +08:00
Jp
08817af0ca test 2026-02-26 14:00:19 +08:00
Jp
afb7cefdda test 2026-02-26 13:56:10 +08:00
Jp
08fe589ad6 test 2026-02-26 13:54:47 +08:00
Jp
1937e26251 test 2026-02-26 13:46:33 +08:00
Jp
1dbc32722a 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
2026-02-26 13:44:36 +08:00
Jp
a4124ceaa9 test 2026-02-26 13:42:31 +08:00
Jp
8b23298196 test 2026-02-26 13:39:45 +08:00
Jp
3c251e9c3a test 2026-02-26 13:36:40 +08:00
Jp
f635dabbc5 test 2026-02-26 13:34:20 +08:00
Jp
e0f459f9ea refactor(Dockerfile): simplify image build and permission handling
- Use fully qualified image names for clarity
- Remove manual PHP extension installation as base image likely includes them
- Leverage COPY --chown to set permissions directly
- Remove redundant permission fix commands
- Keep same final command and exposed port
2026-02-26 13:33:07 +08:00
Jp
8c414e7e70 build: switch to thecodingmachine PHP image for enhanced features
The base image is changed from the official php:8.4-fpm-alpine to thecodingmachine/php:8.4-v4-fpm-alpine to leverage additional pre-installed extensions, configurations, and utilities provided by the TheCodingMachine Docker images, which simplifies the setup for common PHP development and production environments.
2026-02-26 13:31:46 +08:00
Jp
49226f8aa1 build: simplify Dockerfile using extension installer
- Replace manual apk install and docker-php-ext-install with mlocati/docker-php-extension-installer
- Combine system dependency installation and PHP extension setup into a single step
- Reorder steps for better clarity: copy files before permission fixes
- Maintain same PHP extensions and final permissions
2026-02-26 13:27:58 +08:00
Jp
77ed347e36 build: switch to Alpine base image and simplify Dockerfile
- Use php:8.4-fpm-alpine for smaller image size
- Replace apt-get with apk package manager
- Use docker-php-ext-install instead of external extension installer
- Remove unnecessary comments and clean up cache appropriately
2026-02-26 13:17:33 +08:00
Jp
4ade74421c chore(docker): switch to mlocati's PHP extension installer
The docker-php-ext-install command can have permission issues on some
remote servers when extracting tarballs. Using mlocati/docker-php-extension-installer
provides a more reliable method for installing PHP extensions in Docker
containers.
2026-02-26 12:54:55 +08:00
Jp
8e3913bda8 fix(Dockerfile): replace php extension installer with docker-php-ext-install
The third-party extension installer (mlocati/docker-php-extension-installer) was causing tar permission issues on the remote server. Using the standard `docker-php-ext-install` method resolves this compatibility problem.
2026-02-26 11:44:16 +08:00
Jp
fea727daf4 ci(Docker): add --cleanup flag to install-php-extensions
Add the --cleanup flag to the install-php-extensions command to remove downloaded archives after installation, reducing the final image size.

Use the --no-cache flag for the remote podman build in the deployment script to ensure a clean build from the latest source on the server.
2026-02-26 11:36:50 +08:00
Jp
cea2749252 ci: build image remotely before deploying to server
Previously the image was built locally and pushed to a registry. Now we build directly on the remote server to simplify the deployment flow and avoid registry dependencies.
2026-02-26 11:34:48 +08:00
Jp
5992b28eb5 ci: use rm -f to avoid errors when cleaning up temporary files
The -f flag prevents errors if the files do not exist, ensuring the cleanup step is robust and does not fail the deployment process.
2026-02-26 11:30:32 +08:00
Jp
e6acea80a0 chore(deploy): prepend sudo to kubectl commands in Makefile
Ensure kubectl commands have necessary permissions when generating ConfigMaps during deployment.
2026-02-26 11:29:03 +08:00
Jp
02dbea230c fix(deploy): add sudo to kubectl apply command for proper permissions
The deploy-server target was failing due to insufficient permissions on the remote server. Adding sudo ensures kubectl can apply the deployment configuration.
2026-02-26 11:27:10 +08:00
Jp
07748a7025 chore(Makefile): update server config and improve deployment scripts
- Update default server user, IP, and deployment path to match current environment
- Redirect podman kube down output to /dev/null to reduce noise
- Use /tmp directory for temporary YAML files to avoid WSL permission issues
- Consolidate deployment steps to reduce password prompts during remote deployment
2026-02-26 11:25:54 +08:00
Jp
55d2f61d09 ci: streamline server deployment by reducing SSH prompts
Generate a temporary merged YAML file locally before copying to the server. This reduces the number of SSH/SCP commands from multiple to two, minimizing password prompts and connection overhead.
2026-02-26 11:23:30 +08:00
Jp
aef00b405a chore: remove redundant .env copy commands from deploy targets
The .env file is now expected to be present before running deploy commands. This simplifies the Makefile by removing conditional copy logic that was causing confusion about environment setup.
2026-02-26 11:19:19 +08:00
Jp
ac41090ed3 feat(Makefile): add remote server deployment target
Add deploy-server target to deploy application to a remote Kubernetes cluster.
Includes server configuration variables and uses scp/ssh for file transfer and
kubectl commands for applying configuration and deployment.
2026-02-26 11:14:39 +08:00
Jp
ba9c80b9b4 fix(Dockerfile): set proper permissions and remove CI directories
The previous COPY instruction with --chown flag was not recursively setting permissions. Explicitly set directory and file permissions for the www-data user and remove unnecessary CI directories to reduce image size and potential security exposure.
2026-02-26 11:08:20 +08:00
Jp
618f826e1e ci: improve deployment script verbosity and error handling
- Remove stderr suppression from podman kube down to show potential errors
- Remove @ prefix from kubectl command to show execution in output
- Add comment clarifying the purpose of removing stderr redirection
2026-02-26 11:06:21 +08:00
Jp
baf68078a7 ci: switch from Kubernetes to Podman for local deployment
- Update Dockerfile to use fully qualified composer image name
- Replace kubectl commands with podman kube play/down in Makefile
- Change from Kubernetes Secret to ConfigMap for environment variables
- Set imagePullPolicy to Never and use localhost/ prefix for local images
- Reduce replica count to 1 for local development
- Add stop target to Makefile for easier cleanup
2026-02-26 10:55:30 +08:00
Jp
87fd507618 chore(docker): move WORKDIR declaration earlier and reorder steps
Set working directory before copying files to avoid potential conflicts with host files. Also reorder Dockerfile steps for better logical flow and maintainability.
2026-02-25 22:52:20 +08:00
Jp
a697100103 chore(docker): ignore CI directories and use extension installer
- Add .github and .circleci to .dockerignore to reduce image size
- Replace docker-php-ext-install with mlocati's extension installer for better reliability and maintenance
2026-02-25 22:43:35 +08:00
Jp
dd188724be build(docker): enhance Docker setup with proper dependencies and structure
- Add comprehensive .dockerignore file to exclude unnecessary files
- Update Dockerfile to install required system dependencies and PHP extensions
- Set proper working directory and user permissions
- Use multi-stage build for Composer installation
2026-02-25 22:34:05 +08:00
4 changed files with 78 additions and 17 deletions

17
.dockerignore Normal file
View File

@@ -0,0 +1,17 @@
.git
.github
.circleci
.env
.env.local
node_modules
vendor
storage/logs/*
storage/framework/cache/*
bootstrap/cache/*
.phpunit.result.cache
.idea
.vscode
.devcontainer
docker-compose.yml
Makefile
k8s/

View File

@@ -1,6 +1,40 @@
FROM php:8.4-fpm
FROM docker.io/alpine:3.21
COPY . /app
WORKDIR /app
RUN apk add --no-cache \
php84 \
php84-fpm \
php84-pdo_mysql \
php84-mbstring \
php84-exif \
php84-pcntl \
php84-bcmath \
php84-gd \
php84-zip \
php84-intl \
php84-curl \
php84-tokenizer \
php84-xml \
php84-xmlwriter \
php84-xmlreader \
php84-dom \
php84-session \
php84-fileinfo \
php84-openssl \
git \
curl
RUN ln -sf /usr/bin/php84 /usr/bin/php
WORKDIR /var/www
# Copy the application files
COPY --chown=root:root . .
COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer
RUN rm -rf .circleci .github 2>/dev/null || true && \
chmod -R 775 storage bootstrap/cache 2>/dev/null || true
EXPOSE 8000
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]

View File

@@ -1,11 +1,21 @@
IMG := mkm-admin
build:
@echo "Building image from project root..."
podman build -t $(IMG) .
deploy: build
@if [ ! -f .env ]; then cp .env.example .env; fi
kubectl create secret generic mkm-admin-env --from-env-file=.env --dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f k8s/deployment.yaml
@echo "Cleaning up existing deployment if any..."
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
@echo "Generating merged deployment with ConfigMap..."
@sudo kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > /tmp/merged_deployment.yaml
@echo "---" >> /tmp/merged_deployment.yaml
@cat k8s/deployment.yaml >> /tmp/merged_deployment.yaml
@echo "Deploying via podman kube play..."
podman kube play /tmp/merged_deployment.yaml
@rm -f /tmp/merged_deployment.yaml
.PHONY: build deploy
stop:
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
.PHONY: build deploy stop

View File

@@ -5,7 +5,7 @@ metadata:
labels:
app: mkm-admin
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app: mkm-admin
@@ -16,13 +16,13 @@ spec:
spec:
containers:
- name: mkm-admin
image: mkm-admin:latest
imagePullPolicy: Always
image: localhost/mkm-admin:latest
imagePullPolicy: Never
ports:
- containerPort: 8000
envFrom:
- secretRef:
name: mkm-admin-env
- configMapRef:
name: mkm-admin-config
resources:
requests:
cpu: "100m"
@@ -52,12 +52,12 @@ spec:
spec:
containers:
- name: worker
image: mkm-admin:latest
imagePullPolicy: Always
image: localhost/mkm-admin:latest
imagePullPolicy: Never
command: ["php", "artisan", "horizon"]
envFrom:
- secretRef:
name: mkm-admin-env
- configMapRef:
name: mkm-admin-config
resources:
requests:
cpu: "100m"