diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..8f7c98f --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,24 @@ +pipeline: + backend: + image: rust + # environment: + # - DATABASE_URL=postgres://postgres:password@database:5432/postgres + commands: + # - make migrate + - make + - make test + + publish: + image: plugins/docker + settings: + username: realaravinth + password: + from_secret: DOCKER_TOKEN + repo: realaravinth/librepages-forms + tags: latest + + #services: + # database: + # image: postgres + # environment: + # - POSTGRES_PASSWORD=password diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..965792e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM rust:latest as planner +RUN cargo install cargo-chef +WORKDIR /src +COPY . /src/ +RUN cargo chef prepare --recipe-path recipe.json + +FROM rust:latest as cacher +WORKDIR /src/ +RUN cargo install cargo-chef +COPY --from=planner /src/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json + +FROM rust:latest as rust +WORKDIR /src +COPY . . +COPY --from=cacher /src/target target +#COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/ +RUN cargo --version +#RUN make cache-bust +RUN cargo build --release + +FROM debian:bullseye as conductor +LABEL org.opencontainers.image.source https://git.batsense.net/librepages/conductor +RUN apt-get update && apt-get install -y ca-certificates +RUN useradd -ms /bin/bash -u 1001 conductor +WORKDIR /home/conductor +COPY --from=rust /src/target/release/conductor /usr/local/bin/ +#COPY --from=rust /src/config/default.toml /etc/conductor/config.toml +RUN mkdir /var/lib/conductor && chown conductor:conductor /var/lib/conductor +USER conductor +CMD [ "/usr/local/bin/conductor" ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b7f57da --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +default: ## Build app in debug mode + cargo build + +check: ## Check for syntax errors on all workspaces + cargo check --workspace --tests --all-features + +clean: ## Delete build artifacts + @cargo clean + +coverage: ## Generate code coverage report in HTML format + $(call cache_bust) + cargo tarpaulin -t 1200 --out Html + +doc: ## Generate documentation + #yarn doc + cargo doc --no-deps --workspace --all-features + +docker: ## Build Docker image + docker build -t realaravinth/librepages-conductor:master -t realaravinth/librepages-conductor:latest . + +docker-publish: docker ## Build and publish Docker image + docker push realaravinth/librepages-conductor:master + docker push realaravinth/librepages-conductor:latest + +env: ## Setup development environtment + cargo fetch + +lint: ## Lint codebase + cargo fmt -v --all -- --emit files + cargo clippy --workspace --tests --all-features + +#migrate: ## run migrations +# unset DATABASE_URL && cargo build +# cargo run -- migrate + +release: ## Build app with release optimizations + cargo build --release + +run: ## Run app in debug mode + cargo run + + +#sqlx-offline-data: ## prepare sqlx offline data +# cargo sqlx prepare \ +# --database-url=${POSTGRES_DATABASE_URL} -- \ +# --all-features + +test: ## Run all available tests + cargo test --no-fail-fast + +xml-test-coverage: ## Generate code coverage report in XML format + cargo tarpaulin -t 1200 --out Xml + +help: ## Prints help for targets with comments + @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'