Docker images
This commit is contained in:
parent
d056689f57
commit
b7044111f4
59
.gitea/workflows/deploy.yml
Normal file
59
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,59 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract Tag Name
|
||||
id: extract_tag
|
||||
run: |
|
||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
rooftopenergy/waba-test:${{ steps.extract_tag.outputs.tag }}
|
||||
|
||||
- name: Install sshpass
|
||||
run: sudo apt-get update && sudo apt-get install -y sshpass
|
||||
|
||||
- name: Deploy to VPS
|
||||
env:
|
||||
SSHPASS: ${{ secrets.VPS_PASSWORD }}
|
||||
run: |
|
||||
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} << EOF
|
||||
set -e
|
||||
|
||||
echo "Using tag: ${{ steps.extract_tag.outputs.tag }}"
|
||||
|
||||
cd /root/waba-test
|
||||
|
||||
sed -i "s|rooftopenergy/waba-test:.*|rooftopenergy/waba-test:${{ steps.extract_tag.outputs.tag }}|g" docker-compose.yml
|
||||
|
||||
docker compose down
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
EOF
|
||||
38
Dockerfile
Normal file
38
Dockerfile
Normal file
@ -0,0 +1,38 @@
|
||||
# Use official Python base image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
POETRY_VERSION=2.1.3
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl build-essential libpq-dev gcc \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 - && \
|
||||
ln -s /root/.local/bin/poetry /usr/local/bin/poetry
|
||||
|
||||
# Copy pyproject and poetry.lock to leverage Docker cache
|
||||
COPY pyproject.toml poetry.lock* /app/
|
||||
|
||||
# Configure Poetry to not create virtualenvs
|
||||
RUN poetry config virtualenvs.create false
|
||||
|
||||
# Install dependencies
|
||||
RUN poetry install --no-interaction --no-ansi --no-root
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . /app
|
||||
|
||||
# Expose the port FastAPI will run on
|
||||
EXPOSE 8000
|
||||
|
||||
# Start the FastAPI app using uvicorn
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Loading…
x
Reference in New Issue
Block a user