diff --git a/.env.example b/.env.example index b5278d7..0531fe6 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,6 @@ DB_PASS= DB_NAME= DB_PORT=5432 -NGINX_PORT=80 GOLANG_PORT=8888 APP_ENV=localhost JWT_SECRET= diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..a7096e6 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy Application + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Setup SSH + run: | + echo "Setting up SSH..." + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + echo "SSH key setup complete" + ls -la ~/.ssh/id_rsa + + - name: Deploy + shell: bash + env: + SSH_USER: ${{ secrets.SSH_USER }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_PORT: ${{ secrets.SSH_PORT }} + DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} + run: | + echo "Starting deployment..." + echo "Debug: User=$SSH_USER Host=$SSH_HOST Port=$SSH_PORT" + + if [ -z "$SSH_USER" ] || [ -z "$SSH_HOST" ] || [ -z "$SSH_PORT" ]; then + echo "Error: Required SSH variables are not set" + exit 1 + fi + + DEST="${SSH_USER}@${SSH_HOST}" + echo "Connecting to $DEST" + + ssh -i ~/.ssh/id_rsa \ + -p "${SSH_PORT}" \ + -o StrictHostKeyChecking=no \ + "${DEST}" \ + "cd ${DEPLOY_PATH} && \ + git pull && \ + docker compose up -d --build" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f211d8c..44bc1e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,41 +8,11 @@ services: - .:/app ports: - ${GOLANG_PORT:-8888}:8888 - networks: - - app-network - - nginx: - image: nginx:latest - container_name: ${APP_NAME:-go-gin-clean-starter}-nginx - ports: - - ${NGINX_PORT:-81}:80 - volumes: - - .:/var/www/html - - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf - depends_on: - - app - networks: - - app-network - - postgres: - hostname: postgres - container_name: ${APP_NAME:-go-gin-clean-starter}-db - image: postgres:latest - ports: - - 15432:5432 - volumes: - - ./docker/postgresql/tmp:/var/lib/postgresql/data - - app-data:/var/lib/postgresql/data - environment: - - POSTGRES_USER=${DB_USER} - - POSTGRES_PASSWORD=${DB_PASS} - - POSTGRES_DB=${DB_NAME} - networks: - - app-network volumes: app-data: networks: - app-network: - driver: bridge + default: + name: production + external: true \ No newline at end of file