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]
|
[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
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM rust:1.82.0-slim-bullseye AS build
|
FROM rust:1.82.0-slim-bullseye AS deps
|
||||||
WORKDIR /app
|
|
||||||
ARG APP_NAME=mastodon-image-uploader-bot
|
|
||||||
|
|
||||||
RUN apt update && apt install pkg-config openssl libssl-dev -y
|
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 \
|
FROM deps AS test
|
||||||
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
|
COPY .cargo .cargo
|
||||||
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
|
COPY config.toml config.toml
|
||||||
<<EOF
|
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
|
set -e
|
||||||
cargo build --locked --release
|
cargo build --locked --release
|
||||||
ls ./target/release/$APP_NAME
|
ls ./target/release/$APP_NAME
|
||||||
|
@ -18,7 +25,7 @@ EOF
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
ARG UID=10001
|
ARG UID=10001
|
||||||
RUN adduser \
|
RUN adduser \
|
||||||
|
|
24
compose.yaml
24
compose.yaml
|
@ -1,9 +1,9 @@
|
||||||
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
|
||||||
|
@ -14,26 +14,24 @@ services:
|
||||||
|
|
||||||
bot-api:
|
bot-api:
|
||||||
image: git.fai.st/fedi-image-bot/bot-api:v1.0.2
|
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:1.82.0-slim-bullseye
|
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:
|
||||||
|
|
Loading…
Reference in New Issue