-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from jsuereth/create-docker-image
Add docker image and publishing rules for weaver
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
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,54 @@ | ||
name: Weaver Docker Generator | ||
on: | ||
push: | ||
tags: [ '**' ] | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/publish-docker.yml | ||
- 'src/**' | ||
- 'creates/**' | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build the Docker image | ||
run: docker build . -t weaver && docker run --rm weaver --help | ||
|
||
build-and-publish-docker: | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build the Docker image | ||
run: docker build . -t weaver | ||
- name: Push the Docker image | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
function tag_and_push { | ||
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}" | ||
} | ||
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then | ||
tag_and_push "latest" | ||
elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
TAG="${GITHUB_REF#"refs/tags/v"}" | ||
tag_and_push "${TAG}" | ||
else | ||
tag_and_push "${GITHUB_REF#"refs/tags/"}" | ||
fi | ||
- name: Push the Dev Docker image | ||
if: startsWith(github.ref, 'refs/heads/feature/') | ||
run: | | ||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
function tag_and_push { | ||
docker tag weaver "otel/weaver:${1}" && docker push "otel/weaver:${1}" | ||
} | ||
TAG="${GITHUB_REF#"refs/heads/"}" | ||
TAG="${TAG/"/"/"-"}" | ||
tag_and_push "${TAG}" |
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,21 @@ | ||
|
||
# The build image | ||
FROM rust:1.76.0-alpine3.18 as weaver-build | ||
RUN apk add musl-dev | ||
WORKDIR /build | ||
# list out directories to avoid pulling local cargo `target/` | ||
COPY Cargo.toml /build/Cargo.toml | ||
COPY Cargo.lock /build/Cargo.lock | ||
COPY crates /build/crates | ||
COPY data /build/data | ||
COPY src /build/src | ||
COPY templates /build/templates | ||
COPY tests build/tests | ||
RUN cargo build --release | ||
|
||
# The runtime image | ||
FROM alpine:3.18.3 | ||
LABEL maintainer="The OpenTelemetry Authors" | ||
WORKDIR /weaver | ||
COPY --from=weaver-build /build/target/release/weaver /weaver/weaver | ||
ENTRYPOINT ["/weaver/weaver"] |