Publish docker images for chartered-web/chartered-git
Diff
.dockerignore | 4 ++++
Dockerfile | 19 -------------------
Dockerfile-git | 22 ++++++++++++++++++++++
Dockerfile-web | 22 ++++++++++++++++++++++
chartered-git/Cargo.toml | 4 ++++
chartered-web/Cargo.toml | 4 ++++
.github/workflows/docker-publish.yml | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 156 insertions(+), 19 deletions(-)
@@ -1,0 +1,4 @@
Dockerfile-git
Dockerfile-web
.dockerfile
target/
@@ -1,19 +1,0 @@
FROM rust:alpine AS builder
RUN apk add --update gcc g++ build-base alpine-sdk sqlite-dev openssl-dev postgresql-dev
WORKDIR /app
COPY . /app
RUN cargo build --release --features postgres
FROM alpine AS chartered-git
RUN apk add --update postgresql-dev && \
ln -s /lib/ld-musl-$(uname -m).so.1 /lib/ld-linux-$(uname -m).so.1
WORKDIR /app
COPY --from=builder /app/target/release/chartered-git /app/chartered-git
ENTRYPOINT ["/app/chartered-git"]
FROM alpine AS chartered-web
RUN apk add --update postgresql-dev && \
ln -s /lib/ld-musl-$(uname -m).so.1 /lib/ld-linux-$(uname -m).so.1
WORKDIR /app
COPY --from=builder /app/target/release/chartered-web /app/chartered-web
ENTRYPOINT ["/app/chartered-web"]
@@ -1,0 +1,22 @@
FROM lukemathwalker/cargo-chef:latest-rust-slim-bullseye AS chef
WORKDIR /app
FROM chef AS planner
COPY . /app
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
RUN apt update && apt install -y pkg-config make libpq-dev libssl-dev
ARG DEBIAN_FRONTEND=noninteractive
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . /app
RUN cargo build --release --features postgres --bin chartered-git
FROM debian:bullseye-slim
LABEL org.opencontainers.image.source https://github.com/w4/chartered
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y libpq-dev libssl-dev && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/chartered-git /app/chartered-git
ENTRYPOINT ["/app/chartered-git"]
@@ -1,0 +1,22 @@
FROM lukemathwalker/cargo-chef:latest-rust-slim-bullseye AS chef
WORKDIR /app
FROM chef AS planner
COPY . /app
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
RUN apt update && apt install -y pkg-config make libpq-dev libssl-dev
ARG DEBIAN_FRONTEND=noninteractive
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . /app
RUN cargo build --release --features postgres --bin chartered-web
FROM debian:bullseye-slim
LABEL org.opencontainers.image.source https://github.com/w4/chartered
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y libpq-dev libssl-dev && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/chartered-web /app/chartered-web
ENTRYPOINT ["/app/chartered-web"]
@@ -36,3 +36,7 @@
tracing = "0.1"
tracing-subscriber = "0.3"
url = "2"
[features]
sqlite = ["chartered-db/sqlite"]
postgres = ["chartered-db/postgres"]
@@ -40,3 +40,7 @@
tracing = "0.1"
tracing-subscriber = "0.3"
url = { version = "2.2", features = ["serde"] }
[features]
sqlite = ["chartered-db/sqlite"]
postgres = ["chartered-db/postgres"]
@@ -1,0 +1,100 @@
name: Create and publish Docker images
on:
push:
branches: [ main ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
jobs:
build-and-push-chartered-web:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/w4/chartered-web
- name: Build and push chartered-web
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: ./Dockerfile-web
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-chartered-git:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/w4/chartered-git
- name: Build and push chartered-git
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: ./Dockerfile-git
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}