Publish docker images with a woodpecker pipeline #22

Open
Armael wants to merge 3 commits from Armael/tricot:deploy-docker into main
3 changed files with 20 additions and 25 deletions

View file

@ -17,9 +17,9 @@ steps:
- name: build
image: nixpkgs/nix:nixos-22.05
commands:
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.debug
- nix build -j4 --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.debug
- name: test
image: nixpkgs/nix:nixos-22.05
commands:
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.test
- nix build -j4 --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.test

18
.woodpecker/publish.yaml Normal file
View file

@ -0,0 +1,18 @@
when:
event:
- deployment
- cron
steps:
- name: docker build and publish
image: nixpkgs/nix:nixos-22.05
environment:
DOCKER_AUTH:
from_secret: docker_auth
commands:
- mkdir -p /root/.docker
- echo $DOCKER_AUTH > /root/.docker/config.json
- export CONTAINER_TAG=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
- nix-build -j4 --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.docker
- nix-shell -p gzip --run "gunzip -c ./result > image.tar"
- nix-shell -p crane --run "crane push ./image.tar dxflrs/tricot:$CONTAINER_TAG"

View file

@ -1,23 +0,0 @@
FROM rust:1.68-buster as builder
RUN apt-get update && \
apt-get install -y libssl-dev pkg-config
WORKDIR /srv
# Build dependencies and cache them
COPY Cargo.* ./
RUN mkdir -p src && \
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
cargo build --release && \
rm -r src && \
rm target/release/deps/tricot*
# Build final app
COPY ./src ./src
RUN cargo build --release
FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y libssl1.1 iptables ca-certificates
COPY --from=builder /srv/target/release/tricot /usr/local/sbin/tricot
CMD ["/usr/local/sbin/tricot"]