mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
feat: add Docker configuration files and self-deployment workflow
This commit is contained in:
parent
e081c54624
commit
50846c91c2
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
node_modules
|
||||||
|
.nuxt
|
||||||
|
.output
|
||||||
|
.next
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
.env
|
34
.github/workflows/self_deploy.yml
vendored
Normal file
34
.github/workflows/self_deploy.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Server Deployment Request
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Send deployment request
|
||||||
|
id: deploy-request
|
||||||
|
run: |
|
||||||
|
echo "Sending deployment request to server..."
|
||||||
|
RESPONSE=$(curl -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--http1.1 \
|
||||||
|
--fail \
|
||||||
|
--silent \
|
||||||
|
--show-error \
|
||||||
|
"${{ secrets.DEPLOY_URL }}" || echo "Failed to send request")
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Deployment request sent successfully"
|
||||||
|
echo "Response: $RESPONSE"
|
||||||
|
else
|
||||||
|
echo "Error sending deployment request"
|
||||||
|
exit 1
|
||||||
|
fi
|
28
Dockerfile
Executable file
28
Dockerfile
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
# Building process
|
||||||
|
FROM oven/bun:latest as builder
|
||||||
|
WORKDIR /app
|
||||||
|
# Copy dependency files
|
||||||
|
COPY package.json bun.lockb ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
# Copy source files
|
||||||
|
COPY . .
|
||||||
|
# Framework-specific build command
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
# Production image
|
||||||
|
FROM oven/bun:latest
|
||||||
|
WORKDIR /app
|
||||||
|
# Copy built assets and dependencies
|
||||||
|
COPY --from=builder /app/.output /app/.output
|
||||||
|
COPY --from=builder /app/dist /app/dist
|
||||||
|
COPY --from=builder /app/build /app/build
|
||||||
|
COPY --from=builder /app/package.json /app/package.json
|
||||||
|
COPY --from=builder /app/bun.lockb /app/bun.lockb
|
||||||
|
# If you have customized your output directory, please add your custom one here, or just remove it. :)
|
||||||
|
|
||||||
|
# Install production dependencies only
|
||||||
|
RUN bun install --production --frozen-lockfile
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
# Map the prod command to start via editing your package.json like in the example.package.json
|
||||||
|
CMD ["bun", "run", "start"]
|
15
docker-compose.yml
Executable file
15
docker-compose.yml
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
Loading…
x
Reference in New Issue
Block a user