Compare commits
36 Commits
Author | SHA1 | Date |
---|---|---|
bizcochito | 49a2b2a234 | |
Renovate Bot | c215c16a78 | |
bizcochito | b22221e6c3 | |
Renovate Bot | b7229f2467 | |
Alie | 8fff379f54 | |
Alie | e45088c1a8 | |
bizcochito | 0f307b36cc | |
bizcochito | 89fa9a1e1c | |
bizcochito | dd77f3566f | |
Renovate Bot | c29dcac079 | |
Renovate Bot | 1ab2f26c08 | |
Renovate Bot | ed501bed87 | |
bizcochito | 2b3796ccab | |
Alie | e76b6b85c0 | |
bizcochito | d786d6a1ca | |
bizcochito | ce4c735a55 | |
bizcochito | 07824e1710 | |
Renovate Bot | 13a1d2e149 | |
Renovate Bot | 7ec6c63496 | |
Renovate Bot | 4977312f9f | |
bizcochito | 1c62348f18 | |
bizcochito | 04c39ce18b | |
bizcochito | 72cfd516ec | |
Alie | 69199c79a6 | |
Renovate Bot | 13d445c945 | |
Alie | 7fb94e17db | |
Alie | 0c2ee8a69b | |
bizcochito | 6864bb03d2 | |
bizcochito | c0f9a83138 | |
bizcochito | 8200539456 | |
bizcochito | b98e3c69a4 | |
bizcochito | 4f2b18b447 | |
Alie | ceb57052ed | |
Renovate Bot | 1c6999cef2 | |
Alie | fdad62f0b2 | |
Alie | 02981fefb3 |
|
@ -1,2 +1,2 @@
|
||||||
[alias]
|
[alias]
|
||||||
t="test -- --test-threads=1"
|
t = "test -- --test-threads=1 --nocapture"
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Include any files or directories that you don't want to be copied to your
|
|
||||||
# container here (e.g., local build artifacts, temporary files, etc.).
|
|
||||||
#
|
|
||||||
# For more help, visit the .dockerignore file reference guide at
|
|
||||||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
|
|
||||||
|
|
||||||
**/.DS_Store
|
|
||||||
**/.classpath
|
|
||||||
**/.dockerignore
|
|
||||||
**/.env
|
|
||||||
**/.git
|
|
||||||
**/.gitignore
|
|
||||||
**/.project
|
|
||||||
**/.settings
|
|
||||||
**/.toolstarget
|
|
||||||
**/.vs
|
|
||||||
**/.vscode
|
|
||||||
**/*.*proj.user
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/charts
|
|
||||||
**/docker-compose*
|
|
||||||
**/compose*
|
|
||||||
**/Dockerfile*
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
**/secrets.dev.yaml
|
|
||||||
**/values.dev.yaml
|
|
||||||
/bin
|
|
||||||
/target
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
||||||
config.toml
|
|
||||||
mastodon-data.toml
|
|
||||||
*.yaml
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: Unit Tests with docker compose and cargo
|
name: Unit Tests with docker compose and cargo
|
||||||
on: [push, pull_request]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
unit-test:
|
unit-test:
|
||||||
|
@ -15,8 +15,8 @@ jobs:
|
||||||
- name: Installing necessary packages
|
- name: Installing necessary packages
|
||||||
run: apk add nodejs git curl bash
|
run: apk add nodejs git curl bash
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Get access token from secret
|
- name: Get access token from secret
|
||||||
run: echo "${{ secrets.MASTODON_SECRET }}" > mastodon-data.toml
|
run: echo "${{ secrets.MASTODON_SECRET }}" > mastodon-data.toml
|
||||||
- name: Run tests on docker
|
- name: Run tests on docker
|
||||||
run: docker compose down -v && docker compose run bot t
|
run: docker compose down -v && docker compose run bot t
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
name: Build image
|
name: Build image
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- .gitea/workflows/02_build.yaml
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- build
|
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
container:
|
container:
|
||||||
|
@ -21,32 +21,32 @@ jobs:
|
||||||
- name: Installing necessary packages
|
- name: Installing necessary packages
|
||||||
run: apk add nodejs git curl bash
|
run: apk add nodejs git curl bash
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: https://github.com/docker/metadata-action@v4
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
# list of Docker images to use as base name for tags
|
# list of Docker images to use as base name for tags
|
||||||
images: |
|
images: |
|
||||||
git.fai.st/fedi-image-bot/mastodon-image-uploader-bot
|
git.fai.st/fedi-image-bot/mastodon-image-uploader-bot
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
type=raw,value=latest
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=semver,pattern={{raw}}
|
type=semver,pattern={{raw}}
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to fai.st docker registry
|
- name: Login to fai.st docker registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.fai.st
|
registry: git.fai.st
|
||||||
username: ${{ secrets.DOCKER_USER }}
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
password: ${{ secrets.DOCKER_PASS }}
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
58
Dockerfile
58
Dockerfile
|
@ -1,50 +1,32 @@
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
# Comments are provided throughout this file to help you get started.
|
FROM rust:1.83.0-slim-bullseye AS deps
|
||||||
# If you need more help, visit the Dockerfile reference guide at
|
|
||||||
# https://docs.docker.com/engine/reference/builder/
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Create a stage for building the application.
|
|
||||||
|
|
||||||
ARG RUST_VERSION=1.71.0
|
|
||||||
ARG APP_NAME=mastodon-image-uploader-bot
|
|
||||||
FROM rust:${RUST_VERSION}-slim-bullseye AS build
|
|
||||||
ARG APP_NAME
|
|
||||||
WORKDIR /app
|
|
||||||
RUN apt update && apt install pkg-config openssl libssl-dev -y
|
RUN apt update && apt install pkg-config openssl libssl-dev -y
|
||||||
# Build the application.
|
WORKDIR /app
|
||||||
# Leverage a cache mount to /usr/local/cargo/registry/
|
COPY src src
|
||||||
# for downloaded dependencies and a cache mount to /app/target/ for
|
COPY Cargo.toml Cargo.toml
|
||||||
# compiled dependencies which will speed up subsequent builds.
|
COPY Cargo.lock Cargo.lock
|
||||||
# Leverage a bind mount to the src directory to avoid having to copy the
|
|
||||||
# source code into the container. Once built, copy the executable to an
|
FROM deps AS test
|
||||||
# output directory before the cache mounted /app/target is unmounted.
|
COPY .cargo .cargo
|
||||||
RUN --mount=type=bind,source=src,target=src \
|
COPY config.toml config.toml
|
||||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
COPY mastodon-data.toml mastodon-data.toml
|
||||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
RUN cargo build
|
||||||
<<EOF
|
|
||||||
|
FROM deps AS build
|
||||||
|
ARG APP_NAME=mastodon-image-uploader-bot
|
||||||
|
WORKDIR /app
|
||||||
|
RUN <<EOF
|
||||||
set -e
|
set -e
|
||||||
cargo build --locked --release
|
cargo build --locked --release
|
||||||
|
ls ./target/release/$APP_NAME
|
||||||
cp ./target/release/$APP_NAME /bin/bot
|
cp ./target/release/$APP_NAME /bin/bot
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Create a new stage for running the application that contains the minimal
|
|
||||||
# runtime dependencies for the application. This often uses a different base
|
|
||||||
# image from the build stage where the necessary files are copied from the build
|
|
||||||
# stage.
|
|
||||||
#
|
|
||||||
# The example below uses the debian bullseye image as the foundation for running the app.
|
|
||||||
# By specifying the "bullseye-slim" tag, it will also use whatever happens to be the
|
|
||||||
# most recent version of that tag when you build your Dockerfile. If
|
|
||||||
# reproducability is important, consider using a digest
|
|
||||||
# (e.g., debian@sha256:ac707220fbd7b67fc19b112cee8170b41a9e97f703f588b2cdbbcdcecdd8af57).
|
|
||||||
FROM debian:bullseye-slim AS final
|
FROM debian:bullseye-slim AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt update && apt install pkg-config openssl libssl-dev curl -y
|
RUN apt update && apt install pkg-config openssl libssl-dev -y
|
||||||
# Create a non-privileged user that the app will run under.
|
|
||||||
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
|
||||||
ARG UID=10001
|
ARG UID=10001
|
||||||
RUN adduser \
|
RUN adduser \
|
||||||
--disabled-password \
|
--disabled-password \
|
||||||
|
@ -54,8 +36,6 @@ RUN adduser \
|
||||||
botuser
|
botuser
|
||||||
USER botuser
|
USER botuser
|
||||||
|
|
||||||
# Copy the executable from the "build" stage.
|
|
||||||
COPY --from=build /bin/bot /bin/
|
COPY --from=build /bin/bot /bin/
|
||||||
|
|
||||||
# What the container should run when it is started.
|
|
||||||
CMD ["/bin/bot"]
|
CMD ["/bin/bot"]
|
||||||
|
|
30
compose.yaml
30
compose.yaml
|
@ -1,11 +1,9 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
image: mongo:bionic
|
image: mongo:bionic
|
||||||
container_name: mongodb
|
container_name: mongodb-bot-cron
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
- 27017:27017
|
||||||
environment:
|
environment:
|
||||||
MONGO_INITDB_ROOT_USERNAME: root
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
MONGO_INITDB_ROOT_PASSWORD: password
|
MONGO_INITDB_ROOT_PASSWORD: password
|
||||||
|
@ -15,27 +13,25 @@ services:
|
||||||
- mongodb_data:/data/db
|
- mongodb_data:/data/db
|
||||||
|
|
||||||
bot-api:
|
bot-api:
|
||||||
image: git.fai.st/fedi-image-bot/bot-api:v1.0.0
|
image: git.fai.st/fedi-image-bot/bot-api:v1.0.2
|
||||||
container_name: bot-api
|
container_name: bot-api-bot-cron
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- 8080:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongodb
|
- mongodb
|
||||||
environment:
|
environment:
|
||||||
MONGODB_URI: "mongodb://mongodb:27017/bot"
|
MONGODB_URI: mongodb://mongodb:27017/bot
|
||||||
MONGODB_USER: "root"
|
MONGODB_USER: root
|
||||||
MONGODB_PASS: "password"
|
MONGODB_PASS: password
|
||||||
JWTSECRET: "cooljwtsecret"
|
JWTSECRET: cooljwtsecret
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
image: rust
|
build:
|
||||||
container_name: bot
|
target: test
|
||||||
working_dir: /app
|
|
||||||
entrypoint: ["cargo"]
|
entrypoint: ["cargo"]
|
||||||
|
container_name: bot-cron
|
||||||
depends_on:
|
depends_on:
|
||||||
- bot-api
|
- bot-api
|
||||||
volumes:
|
|
||||||
- ./:/app:rw
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mongodb_data:
|
mongodb_data:
|
||||||
|
|
28
cron.yaml
28
cron.yaml
|
@ -1,28 +0,0 @@
|
||||||
apiVersion: batch/v1beta1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: bot-cronjob
|
|
||||||
spec:
|
|
||||||
schedule: "* */6 * * *" # Runs every 6 hours
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: bot-job
|
|
||||||
image: git.fai.st/fedi-image-bot/mastodon-image-uploader-bot:v1.0.0
|
|
||||||
volumeMounts:
|
|
||||||
- name: config-toml
|
|
||||||
mountPath: /app/config.toml
|
|
||||||
readOnly: true
|
|
||||||
- name: mastodon-token
|
|
||||||
mountPath: /app/mastodon-data.toml
|
|
||||||
readOnly: true
|
|
||||||
restartPolicy: Never
|
|
||||||
volumes:
|
|
||||||
- name: config-toml
|
|
||||||
configMap:
|
|
||||||
name: bot-config-toml
|
|
||||||
- name: mastodon-token
|
|
||||||
secret:
|
|
||||||
secretName: mastodon-data
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
Loading…
Reference in New Issue