mirror of
https://github.com/shiroyashik/doggy-watch.git
synced 2025-12-06 04:21:13 +03:00
This commit is contained in:
parent
5bcfff99a1
commit
591020f04b
11 changed files with 89 additions and 1 deletions
42
.github/workflows/docker-push.yml
vendored
Normal file
42
.github/workflows/docker-push.yml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
name: Docker Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# - name: Checkout code
|
||||||
|
# uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# - name: Login to Docker Hub
|
||||||
|
# uses: docker/login-action@v3
|
||||||
|
# with:
|
||||||
|
# username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
# password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get short SHA
|
||||||
|
id: short_sha
|
||||||
|
run: echo "sha=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
# context: .
|
||||||
|
tags: ghcr.io/${{ github.repository_owner }}/doggy-watch:${{ steps.short_sha.outputs.sha }},ghcr.io/${{ github.repository_owner }}/doggy-watch:latest
|
||||||
|
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/doggy-watch:buildcache
|
||||||
|
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/doggy-watch:buildcache,mode=max
|
||||||
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
||||||
/act
|
/act
|
||||||
.env
|
.env
|
||||||
note.txt
|
note.txt
|
||||||
|
docker-compose.yaml
|
||||||
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -803,6 +803,7 @@ dependencies = [
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"migration",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
"teloxide",
|
"teloxide",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [ "database", "youtube", "database/migration" ]
|
members = [ "database", "youtube", "migration" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
database = { path = "database" }
|
database = { path = "database" }
|
||||||
youtube = { path = "youtube" }
|
youtube = { path = "youtube" }
|
||||||
|
migration = { path = "migration"}
|
||||||
|
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
|
|
|
||||||
39
Dockerfile
Normal file
39
Dockerfile
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
## Chef
|
||||||
|
# FROM clux/muslrust:stable AS chef
|
||||||
|
FROM rust:1.84.0-alpine3.20 AS chef
|
||||||
|
USER root
|
||||||
|
RUN apk add --no-cache musl-dev libressl-dev
|
||||||
|
RUN cargo install cargo-chef
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
## Planner
|
||||||
|
FROM chef AS planner
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY ./migration ./migration
|
||||||
|
COPY ./database ./database
|
||||||
|
COPY ./youtube ./youtube
|
||||||
|
COPY src src
|
||||||
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
|
## Builder
|
||||||
|
FROM chef AS builder
|
||||||
|
COPY --from=planner /build/recipe.json recipe.json
|
||||||
|
# Build dependencies - this is the caching Docker layer!
|
||||||
|
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
|
||||||
|
# Build application
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY ./migration ./migration
|
||||||
|
COPY ./database ./database
|
||||||
|
COPY ./youtube ./youtube
|
||||||
|
COPY src src
|
||||||
|
RUN cargo build --release --target x86_64-unknown-linux-musl --bin doggy-watch
|
||||||
|
|
||||||
|
## Runtime
|
||||||
|
FROM alpine:3.20.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/doggy-watch /app/doggy-watch
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
ENV TZ=Etc/UTC
|
||||||
|
|
||||||
|
ENTRYPOINT [ "./doggy-watch" ]
|
||||||
|
|
@ -2,6 +2,7 @@ use std::{env::var, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use database::moderators;
|
use database::moderators;
|
||||||
|
use migration::{Migrator, MigratorTrait};
|
||||||
use sea_orm::{prelude::*, sea_query::OnConflict, ConnectOptions, Database, Set};
|
use sea_orm::{prelude::*, sea_query::OnConflict, ConnectOptions, Database, Set};
|
||||||
use teloxide::{
|
use teloxide::{
|
||||||
dispatching::dialogue::InMemStorage,
|
dispatching::dialogue::InMemStorage,
|
||||||
|
|
@ -66,6 +67,9 @@ async fn main() -> anyhow::Result<()> {
|
||||||
opt.sqlx_logging_level(tracing::log::LevelFilter::Trace);
|
opt.sqlx_logging_level(tracing::log::LevelFilter::Trace);
|
||||||
let db: DatabaseConnection = Database::connect(opt).await?;
|
let db: DatabaseConnection = Database::connect(opt).await?;
|
||||||
|
|
||||||
|
// applying migrations
|
||||||
|
Migrator::up(&db, None).await?;
|
||||||
|
|
||||||
// add administrators to db
|
// add administrators to db
|
||||||
{
|
{
|
||||||
let admins: Vec<moderators::ActiveModel> = ADMINISTRATORS.iter().map(|&x| {
|
let admins: Vec<moderators::ActiveModel> = ADMINISTRATORS.iter().map(|&x| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue