Modified ci/cd to push dockerfile to dockerhub

main
David 2022-12-29 22:15:49 +01:00
parent 63a0886e37
commit ab7f75b416
4 changed files with 44 additions and 51 deletions

View File

@ -1,49 +1,34 @@
# This file is a template, and might need editing before it works on your project. .caching_rust: &caching_rust
# You can copy and paste this template into a new `.gitlab-ci.yml` file. cache:
# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. paths:
# - .cargo/
# To contribute improvements to CI/CD templates, please follow the Development guide at: - .cache/sccache
# https://docs.gitlab.com/ee/development/cicd/templates.html - target/x86_64-unknown-linux-musl/release/material
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Rust.gitlab-ci.yml
# Official language image. Look for the different tagged releases at: stages:
# https://hub.docker.com/r/library/rust/tags/ - test
image: "rust:latest" - build
# Optional: Pick zero or more services to be used on all builds. run_tests_cargo:
# Only needed when using a docker container to run your tests in. stage: test
# Check out: https://docs.gitlab.com/ee/ci/services/index.html image: "rust:latest"
# services: # Use cargo to test the project
# - mysql:latest
# - redis:latest
# - postgres:latest
# Optional: Install a C compiler, cmake and git into the container.
# You will often need this when you (or any of your dependencies) depends on C code.
# before_script:
# - apt-get update -yqq
# - apt-get install -yqq --no-install-recommends build-essential
# Use cargo to test the project
test:cargo:
script: script:
- rustc --version && cargo --version # Print version info for debugging - rustc --version && cargo --version # Print version info for debugging
- cargo build - cargo build
- cargo test --workspace --verbose - cargo test --workspace --verbose
# Optional: Use a third party library to generate gitlab junit reports docker-build-main:
# test:junit-report: # Official docker image.
# script: image: "docker:latest"
# Should be specified in Cargo.toml stage: build
# - cargo install junitify services:
# - cargo test -- --format=json -Z unstable-options --report-time | junitify --out $CI_PROJECT_DIR/tests/ - docker:dind
# artifacts: before_script:
# when: always - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# reports: script:
# junit: $CI_PROJECT_DIR/tests/*.xml - docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE:latest"
only:
- main
# deploy:
# stage: deploy
# script: echo "Define your deployment script!"
# environment: production

View File

@ -1,8 +1,8 @@
[package] [package]
name = "matrix-modbot" name = "matrix-modbot"
authors = ["David Dai https://www.gitlab.com/david-0609"] authors = ["David (Peiran) Dai https://www.gitlab.com/david-0609"]
version = "0.1.0" version = "0.1.0"
edition = "2021" edition="2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,13 +1,12 @@
# syntax=docker/dockerfile:1 # # syntax=docker/dockerfile:1
FROM rust:latest as builder FROM rust:latest as builder
WORKDIR /usr/src/matrix-modbot
COPY . . COPY . .
RUN cargo build --release RUN cargo build --release
RUN cargo run RUN cargo install --path .
FROM rust:latest FROM debian:stable-slim
COPY --from=builder /target /target COPY --from=builder /usr/local/cargo/bin/matrix-modbot /usr/local/bin/matrix-modbot
COPY --from=builder config.ini config.ini RUN touch config.ini
WORKDIR /target CMD ["matrix-modbot", "config.ini"]
RUN ./matrix-modbot config.ini
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl --fail http://localhost:5000/health || exit 1 HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl --fail http://localhost:5000/health || exit 1

View File

@ -5,3 +5,12 @@ Matrix Modbot is a bot for Matrix used to automatically moderate Matrix rooms.
## Who is this bot for? ## Who is this bot for?
The bot is orientated towards admins of large Matrix rooms that are public and require moderation. With this bot, simple jobs such as swear filtering and spam prevention could be accomplished without intervention of human moderators. The bot is orientated towards admins of large Matrix rooms that are public and require moderation. With this bot, simple jobs such as swear filtering and spam prevention could be accomplished without intervention of human moderators.
## How to run?
**Using Docker:**
docker run -v /local/path/to/config.int:/config.ini -t matrix-modbot:latest
**Using Cargo:**
cargo build --release
cargo run