mirror of
https://github.com/flibusta-apps/telegram_files_server.git
synced 2025-12-06 12:35:39 +01:00
Add building image
This commit is contained in:
43
.github/workflows/build_docker_image.yml
vendored
Normal file
43
.github/workflows/build_docker_image.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Build docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build-Docker-Image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- id: repository_name
|
||||||
|
uses: ASzc/change-string-case-action@v1
|
||||||
|
with:
|
||||||
|
string: ${{ github.repository }}
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
env:
|
||||||
|
IMAGE: ${{ steps.repository_name.outputs.lowercase }}
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: ghcr.io/${{ env.IMAGE }}:latest
|
||||||
|
context: .
|
||||||
|
file: ./docker/production.dockerfile
|
||||||
33
docker/production.dockerfile
Normal file
33
docker/production.dockerfile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
FROM python:3.10-slim as build-image
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install --no-install-recommends -y gcc build-essential python3-dev libpq-dev libffi-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /root/poetry
|
||||||
|
COPY pyproject.toml poetry.lock /root/poetry/
|
||||||
|
|
||||||
|
RUN pip install poetry --no-cache-dir \
|
||||||
|
&& poetry export --without-hashes > requirements.txt
|
||||||
|
|
||||||
|
ENV VENV_PATH=/opt/venv
|
||||||
|
|
||||||
|
RUN python -m venv $VENV_PATH \
|
||||||
|
&& . /opt/venv/bin/activate \
|
||||||
|
&& pip install -r requirements.txt --no-cache-dir
|
||||||
|
|
||||||
|
|
||||||
|
FROM build-image as runtime-image
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./fastapi_file_server/ /app/
|
||||||
|
|
||||||
|
COPY --from=build-image $VENV_PATH $VENV_PATH
|
||||||
|
ENV PATH="$VENV_PATH/bin:$PATH"
|
||||||
|
|
||||||
|
COPY ./scripts/start_production.sh /root/
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD bash /root/start_production.sh
|
||||||
3
scripts/start_production.sh
Normal file
3
scripts/start_production.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
cd /app
|
||||||
|
alembic -c ./app/alembic.ini upgrade head
|
||||||
|
uvicorn main:app --host="0.0.0.0" --port="8080"
|
||||||
Reference in New Issue
Block a user