feat: add .env file generation to deployment workflow and update Dockerfile for production dependencies
Deploy to NAS / deploy (push) Failing after 1m5s

This commit is contained in:
2025-12-24 20:51:28 -05:00
parent abcc60e703
commit f850e1ce1e
3 changed files with 13 additions and 83 deletions
+12 -3
View File
@@ -35,6 +35,15 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y sshpass sudo apt-get install -y sshpass
- name: Generate .env file
run: |
cat > .env << EOF
DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}
CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }}
NANOGPT_API_KEY=${{ secrets.NANOGPT_API_KEY }}
NODE_ENV=production
EOF
- name: Deploy to NAS - name: Deploy to NAS
env: env:
SSH_PASSWORD: ${{ secrets.NAS_SSH_PASSWORD }} SSH_PASSWORD: ${{ secrets.NAS_SSH_PASSWORD }}
@@ -42,9 +51,9 @@ jobs:
# Create app directory on NAS # Create app directory on NAS
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no hllywluis@luis-nas.lan "mkdir -p /mnt/kCloud/Home/hllywluis/kekbot" sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no hllywluis@luis-nas.lan "mkdir -p /mnt/kCloud/Home/hllywluis/kekbot"
# Copy Docker files # Copy Docker files (without .env, it's generated separately)
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile .env hllywluis@luis-nas.lan:/mnt/kCloud/Home/hllywluis/kekbot/ sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile kekbot.tar hllywluis@luis-nas.lan:/mnt/kCloud/Home/hllywluis/kekbot/
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no kekbot.tar hllywluis@luis-nas.lan:/mnt/kCloud/Home/hllywluis/kekbot/ sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no .env hllywluis@luis-nas.lan:/mnt/kCloud/Home/hllywluis/kekbot/
# Load Docker image and deploy # Load Docker image and deploy
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no hllywluis@luis-nas.lan << 'EOF' sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no hllywluis@luis-nas.lan << 'EOF'
+1 -1
View File
@@ -8,7 +8,7 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
# Install dependencies # Install dependencies
RUN npm ci --only=production RUN npm ci --omit=dev
# Copy application files # Copy application files
COPY . . COPY . .
-79
View File
@@ -1,79 +0,0 @@
# Gitea Workflow Deployment to NAS
This guide explains how to set up the Gitea workflow to deploy Kekbot to your NAS via SSH.
## Prerequisites
1. **Docker and Docker Compose** must be installed on your NAS
2. **SSH access** enabled on your NAS with password authentication
## Setup Instructions
### 1. Add SSH Password Secret to Gitea
1. Go to your Gitea repository
2. Navigate to **Settings****Secrets** (or **Actions****Secrets**)
3. Add a new secret named `NAS_SSH_PASSWORD`
4. Set the value to your NAS user password (hllywluis)
### 2. Verify NAS Configuration
Ensure your NAS has:
- Docker installed
- Docker Compose installed
- SSH server running on port 22
- Password authentication enabled for SSH
### 3. Test SSH Access (Optional)
Before running the workflow, you can test SSH access:
```bash
ssh hllywluis@luis-nas.lan
```
## Workflow Configuration
The workflow file is located at [`.gitea/workflows/deploy-nas.yml`](.gitea/workflows/deploy-nas.yml)
### How It Works
1. **Build**: Builds the Docker image locally using Docker Buildx
2. **Save**: Saves the Docker image as a tar archive
3. **Transfer**: Uses `sshpass` to SSH into your NAS and copy files
4. **Deploy**: Loads the Docker image and runs `docker-compose up -d`
### Manual Trigger
You can manually trigger the deployment by:
1. Going to your Gitea repository
2. Navigating to **Actions**
3. Selecting the **Deploy to NAS** workflow
4. Clicking **Run workflow**
## Troubleshooting
### SSH Connection Failed
If the workflow fails with SSH connection issues:
- Verify `NAS_SSH_PASSWORD` secret is set correctly
- Check that the NAS is reachable at `luis-nas.lan`
- Ensure SSH password authentication is enabled on the NAS
### Docker Errors
If Docker fails on the NAS:
- Verify Docker is running: `docker ps`
- Check Docker Compose: `docker-compose --version`
- Review logs: `docker-compose logs`
### Permission Issues
The workflow uses the `hllywluis` user. If you need a different user:
1. Update the `hllywluis@luis-nas.lan` in the workflow file
2. Adjust the `/mnt/kCloud/Home/hllywluis/kekbot` directory permissions accordingly