-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
344 changed files
with
69,741 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Publish API Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- monorepo | ||
paths: | ||
- 'api/**' | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4.1.1 | ||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) == *"api"* ]]; then | ||
echo "::set-output name=changes::true" | ||
else | ||
echo "::set-output name=changes::false" | ||
fi | ||
- name: Extract version from pyproject.toml | ||
if: steps.check_changes.outputs.changes == 'true' | ||
id: extract_metadata | ||
run: | | ||
VERSION=$(awk -F ' = ' '/version =/ {gsub(/"/, "", $2); print $2}' api/pyproject.toml) | ||
LABELS="version=$VERSION,latest" | ||
echo "::set-output name=version::$VERSION" | ||
echo "::set-output name=labels::$LABELS" | ||
- name: Log in to Docker Hub | ||
if: steps.check_changes.outputs.changes == 'true' | ||
uses: docker/login-action@v3.0.0 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5.1.0 | ||
if: steps.check_changes.outputs.changes == 'true' | ||
with: | ||
context: ./api | ||
file: ./api/Dockerfile | ||
push: true | ||
tags: ${{ github.repository }}-api-test:${{ steps.extract_metadata.outputs.version }}, ${{ github.repository }}:latest | ||
labels: ${{ steps.extract_metadata.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish Bot Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- monorepo | ||
paths: | ||
- 'src/**' | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4.1.1 | ||
- name: Check for changes | ||
id: check_changes | ||
run: | | ||
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) == *"src"* ]]; then | ||
echo "::set-output name=changes::true" | ||
else | ||
echo "::set-output name=changes::false" | ||
fi | ||
- name: Extract metadata (tags, labels) for Docker | ||
if: steps.check_changes.outputs.changes == 'true' | ||
id: meta | ||
uses: docker/metadata-action@v5.5.1 | ||
with: | ||
images: qwizii/cs2-battle-bot-test | ||
|
||
- name: Log in to Docker Hub | ||
if: steps.check_changes.outputs.changes == 'true' | ||
uses: docker/login-action@v3.0.0 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5.1.0 | ||
if: steps.check_changes.outputs.changes == 'true' | ||
with: | ||
context: ./src | ||
file: ./src/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Stage 1: Install Rust, build dependencies, and prepare the build environment | ||
FROM python:3.11.6-slim AS builder | ||
|
||
WORKDIR /code | ||
|
||
|
||
# Install or upgrade pip and Poetry | ||
RUN pip install --upgrade pip && pip install --no-cache-dir --upgrade poetry | ||
|
||
# Disable Poetry virtualenv creation | ||
RUN poetry config installer.max-workers 10 | ||
RUN poetry config virtualenvs.create false | ||
#RUN poetry config installer.no-binary cryptography | ||
|
||
# Copy the project files for dependency installation | ||
COPY ./pyproject.toml ./poetry.lock /code/ | ||
|
||
# Install project dependencies using Poetry | ||
RUN poetry install --no-interaction --no-ansi | ||
|
||
|
||
|
||
# Stage 2: Runtime environment | ||
FROM builder AS runtime | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Create a dedicated user for running the application | ||
RUN addgroup --system fastapi && adduser --system --ingroup fastapi fastapiuser | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy only the necessary files from the build stage | ||
COPY --from=builder /code /app | ||
|
||
COPY --from=builder /code/pyproject.toml /app/ | ||
|
||
|
||
# Copy the source code | ||
COPY src /app/ | ||
|
||
|
||
# Change ownership to the dedicated user | ||
RUN chown -R fastapiuser:fastapi /app | ||
|
||
# Set the PORT environment variable (customize as needed) | ||
ENV PORT 80 | ||
|
||
# Switch to the dedicated user | ||
USER fastapiuser |
Oops, something went wrong.