Skip to content

Commit

Permalink
Dockerize
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkar598 committed Nov 10, 2024
1 parent 7a1efd9 commit 950c607
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ end_of_line = lf

[*.txt]
insert_final_newline = false

[*.yml]
indent_size = 2
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: [master]

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
strategy:
matrix:
image: [ "mapdiffbot2", "icondiffbot2" ]

runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ matrix.image }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ jobs/

diffbot.pem
config.toml

/config/
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ members = [
]

[profile.release]
lto = true
#lto = true
debug = true
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM rust:1.82.0-slim-bookworm AS builder

RUN apt-get update && apt-get install -y pkg-config libssl-dev make

WORKDIR /app

COPY . .
RUN --mount=type=cache,target=/app/target \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release && cp target/release/mapdiffbot2 target/release/icondiffbot2 .

FROM debian:bookworm-20241016-slim AS base

RUN apt-get update && apt-get install -y libssl3
USER 1000
WORKDIR /app

FROM base AS mapdiffbot2
COPY --from=builder /app/mapdiffbot2 /app/mapdiffbot2

ENTRYPOINT /app/mapdiffbot2

FROM base AS icondiffbot2
COPY --from=builder /app/icondiffbot2 /app/icondiffbot2

ENTRYPOINT /app/icondiffbot2
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
icondiffbot2:
image: ghcr.io/spacestation13/icondiffbot2:latest
build:
target: icondiffbot2
init: true
volumes:
- type: bind
source: ./config/icondiffbot2.toml
target: /app/config.toml
read_only: true
- type: bind
source: ./config/config
target: /app/config
read_only: true
- icondiffbot2_images:/app/images
mapdiffbot2:
image: ghcr.io/spacestation13/mapdiffbot2:latest
build:
target: mapdiffbot2
init: true
volumes:
- type: bind
source: ./config/mapdiffbot2.toml
target: /app/config.toml
read_only: true
- type: bind
source: ./config/config
target: /app/config
read_only: true
- mapdiffbot2_images:/app/images
- mapdiffbot2_repos:/app/repos
volumes:
icondiffbot2_images:
mapdiffbot2_images:
mapdiffbot2_repos:

0 comments on commit 950c607

Please sign in to comment.