Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ci #2

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions .github/workflows/deploy.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Use the official Python image as the base image
FROM python:3.10-slim-bookworm AS base

# Install uv
# Copy uv binaries
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Set environment variables
Expand All @@ -15,17 +15,17 @@ ENV PORT=8080
# Set the working directory
WORKDIR /app

# Copy only the necessary files for dependency installation
# Copy dependency files for installation
COPY pyproject.toml uv.lock ./

# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --system -r pyproject.toml

# Copy the rest of the application code
# Copy the main application file
COPY bot.py ./

# Compile bytecode
# Compile bytecode (this step might be redundant if UV_COMPILE_BYTECODE is set)
RUN python -m compileall .

# Expose the port the app runs on
Expand Down
35 changes: 35 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
steps:
# Build the Docker image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/discord-bot:$COMMIT_SHA'
- '-f'
- 'bot/Dockerfile'
- 'bot'
env:
- 'DOCKER_BUILDKIT=1'

# Push the image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/discord-bot:$COMMIT_SHA'

# Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'discord-bot'
- '--image'
- 'gcr.io/$PROJECT_ID/discord-bot:$COMMIT_SHA'
- '--region'
- 'us-central1'
- '--platform'
- 'managed'

images:
- 'gcr.io/$PROJECT_ID/discord-bot:$COMMIT_SHA'