-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker build #36
Open
alexkar598
wants to merge
9
commits into
spacestation13:master
Choose a base branch
from
alexkar598:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Docker build #36
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
950c607
Dockerize
alexkar598 684ab14
Renames job
alexkar598 610bbfd
Adds information in config folder
alexkar598 0d26f3a
Fixes build action
alexkar598 00a3a64
Enable caching on docker
alexkar598 7ef17b4
Enables buildx
alexkar598 032fb34
Better caching
alexkar598 ab38683
Revert "Better caching"
alexkar598 c81e87d
Reenables LTO
alexkar598 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ end_of_line = lf | |
|
||
[*.txt] | ||
insert_final_newline = false | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# | ||
name: Build and publish 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 | ||
NAMESPACE: ${{ github.repository_owner }} | ||
|
||
# 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: | ||
# Single job at a time to make use of the github cache to only build the rust project once and then build images | ||
max-parallel: 1 | ||
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: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- 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 }}/${{ env.NAMESPACE }}/${{ matrix.image }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
push: true | ||
target: ${{ matrix.image }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Generate artifact attestation | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ matrix.image }} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ jobs/ | |
|
||
diffbot.pem | ||
config.toml | ||
|
||
/config/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ members = [ | |
] | ||
|
||
[profile.release] | ||
lto = true | ||
#lto = true | ||
debug = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Put mapdiffbot2.toml and icondiffbot2.toml here for docker setups. | ||
|
||
The contents of config will be put in /app/config | ||
|
||
Examples can be found in crates/mapdiffbot2/config.example.toml and crates/icondiffbot2/config.example.toml respectively. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
AffectedArc07 marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to do anything fancy with perms to make it upload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it uses the token from github actions to upload to the github registry. If you want to build locally however, you do need to login to the github docker registry