haha, hope it works

This commit is contained in:
ITQ
2025-03-03 01:31:25 +03:00
parent f056101e9e
commit e328bd6b18
4 changed files with 10 additions and 29 deletions
+10
View File
@@ -370,11 +370,21 @@ services:
restart: unless-stopped restart: unless-stopped
shm_size: 4mb shm_size: 4mb
custom_python:
image: gitlab.prodcontest.ru:5050/team-15/project/custom_python:latest
entrypoint: [""]
command: echo "Image pulled."
checker: checker:
image: gitlab.prodcontest.ru:5050/team-15/project/checker:latest image: gitlab.prodcontest.ru:5050/team-15/project/checker:latest
build: build:
context: ./services/checker context: ./services/checker
dockerfile: Dockerfile dockerfile: Dockerfile
depends_on:
custom_python:
restart: false
condition: service_completed_successfully
required: true
env_file: env_file:
- path: ./infrastructure/checker/.env.template - path: ./infrastructure/checker/.env.template
required: true required: true
-6
View File
@@ -1,10 +1,4 @@
# Change all vars before going to production and remove all comments (!) # Change all vars before going to production and remove all comments (!)
# Below all environment variables and default values # Below all environment variables and default values
REGISTRY_USERNAME=
REGISTRY_PASSWORD=
REGISTRY_URL=gitlab.prodcontest.ru:5050
DOCKER_IMAGE=gitlab.prodcontest.ru:5050/team-15/project/custom-python DOCKER_IMAGE=gitlab.prodcontest.ru:5050/team-15/project/custom-python
-6
View File
@@ -7,12 +7,6 @@ BASE_DIR = Path(__file__).resolve().parent
load_dotenv(BASE_DIR / ".env") load_dotenv(BASE_DIR / ".env")
REGISTRY_LOGIN = os.getenv("REGISTRY_USERNAME", None)
REGISTRY_PASSWORD = os.getenv("REGISTRY_USERNAME", None)
REGISTRY_URL = os.getenv("REGISTRY_URL", "gitlab.prodcontest.ru:5050")
DOCKER_IMAGE = os.getenv( DOCKER_IMAGE = os.getenv(
"DOCKER_IMAGE", default="gitlab.prodcontest.ru:5050/team-15/project/custom-python" "DOCKER_IMAGE", default="gitlab.prodcontest.ru:5050/team-15/project/custom-python"
) )
-17
View File
@@ -21,27 +21,10 @@ ALLOWED_FILENAME_CHARS = r"[^a-zA-Z0-9_\-.]"
app = FastAPI() app = FastAPI()
docker_client = docker.from_env() docker_client = docker.from_env()
print(docker_client.login(
username=config.REGISTRY_LOGIN,
password=config.REGISTRY_PASSWORD,
registry=config.REGISTRY_URL,
))
print(config.REGISTRY_LOGIN, config.REGISTRY_PASSWORD)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
@app.on_event("startup")
async def pull_docker_image():
client = docker.from_env()
image_name = config.DOCKER_IMAGE
try:
client.images.pull(image_name)
print(f"Successfully pulled {image_name}")
except docker.errors.DockerException as e:
print(f"Error pulling {image_name}: {e}")
class FileDetails(BaseModel): class FileDetails(BaseModel):
url: HttpUrl = Field( url: HttpUrl = Field(
..., description="URL to download the file from (supports HTTP/HTTPS)" ..., description="URL to download the file from (supports HTTP/HTTPS)"