refactor docker tests and build
Unit Tests with docker compose and cargo / unit-test (push) Successful in 48s
Details
Unit Tests with docker compose and cargo / unit-test (push) Successful in 48s
Details
This commit is contained in:
parent
e45088c1a8
commit
8fff379f54
|
@ -1,2 +1,2 @@
|
|||
[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
|
25
Dockerfile
25
Dockerfile
|
@ -1,15 +1,22 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM rust:1.82.0-slim-bullseye AS build
|
||||
WORKDIR /app
|
||||
ARG APP_NAME=mastodon-image-uploader-bot
|
||||
|
||||
FROM rust:1.82.0-slim-bullseye AS deps
|
||||
RUN apt update && apt install pkg-config openssl libssl-dev -y
|
||||
WORKDIR /app
|
||||
COPY src src
|
||||
COPY Cargo.toml Cargo.toml
|
||||
COPY Cargo.lock Cargo.lock
|
||||
|
||||
RUN --mount=type=bind,source=src,target=src \
|
||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
||||
<<EOF
|
||||
FROM deps AS test
|
||||
COPY .cargo .cargo
|
||||
COPY config.toml config.toml
|
||||
COPY mastodon-data.toml mastodon-data.toml
|
||||
RUN cargo build
|
||||
|
||||
FROM deps AS build
|
||||
ARG APP_NAME=mastodon-image-uploader-bot
|
||||
WORKDIR /app
|
||||
RUN <<EOF
|
||||
set -e
|
||||
cargo build --locked --release
|
||||
ls ./target/release/$APP_NAME
|
||||
|
@ -18,7 +25,7 @@ EOF
|
|||
|
||||
FROM debian:bullseye-slim AS final
|
||||
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
|
||||
|
||||
ARG UID=10001
|
||||
RUN adduser \
|
||||
|
|
24
compose.yaml
24
compose.yaml
|
@ -1,9 +1,9 @@
|
|||
services:
|
||||
mongodb:
|
||||
image: mongo:bionic
|
||||
container_name: mongodb
|
||||
container_name: mongodb-bot-cron
|
||||
ports:
|
||||
- "27017:27017"
|
||||
- 27017:27017
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: password
|
||||
|
@ -14,26 +14,24 @@ services:
|
|||
|
||||
bot-api:
|
||||
image: git.fai.st/fedi-image-bot/bot-api:v1.0.2
|
||||
container_name: bot-api
|
||||
container_name: bot-api-bot-cron
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- 8080:8080
|
||||
depends_on:
|
||||
- mongodb
|
||||
environment:
|
||||
MONGODB_URI: "mongodb://mongodb:27017/bot"
|
||||
MONGODB_USER: "root"
|
||||
MONGODB_PASS: "password"
|
||||
JWTSECRET: "cooljwtsecret"
|
||||
MONGODB_URI: mongodb://mongodb:27017/bot
|
||||
MONGODB_USER: root
|
||||
MONGODB_PASS: password
|
||||
JWTSECRET: cooljwtsecret
|
||||
|
||||
bot:
|
||||
image: rust:1.82.0-slim-bullseye
|
||||
container_name: bot
|
||||
working_dir: /app
|
||||
build:
|
||||
target: test
|
||||
entrypoint: ["cargo"]
|
||||
container_name: bot-cron
|
||||
depends_on:
|
||||
- bot-api
|
||||
volumes:
|
||||
- ./:/app:rw
|
||||
|
||||
volumes:
|
||||
mongodb_data:
|
||||
|
|
Loading…
Reference in New Issue