Skip to content

Commit

Permalink
Add Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
MedovTimur committed Dec 3, 2024
1 parent 0b38ccb commit dc1591f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: [master]

jobs:
build-and-test:
name: Build and Test
build-and-publish:
name: Build, Test and Publish Docker Image
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -54,24 +54,16 @@ jobs:
cp target/wasm32-unknown-unknown/release/*.wasm artifacts/
cp target/wasm32-unknown-unknown/release/*.idl artifacts/
- name: Upload build artifacts
uses: actions/upload-artifact@v3
- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository_owner }}/wasm-artifacts:latest .
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
name: build-artifacts
path: artifacts/*
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish artifacts to GitHub Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to GitHub Packages
run: |
echo "Publishing artifacts to GitHub Packages"
mkdir -p packages
for file in artifacts/*; do
filename=$(basename "$file")
curl -u "${{ secrets.GITHUB_ACTOR }}:${{ secrets.GITHUB_TOKEN }}" \
-X POST \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
https://api.github.com/repos/${{ github.repository }}/packages \
-H "Accept: application/vnd.github.v3+json"
done
docker push ghcr.io/${{ github.repository_owner }}/wasm-artifacts:latest
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rust:1.83 as builder

WORKDIR /usr/src/myapp

COPY . .

RUN cargo build --release --target wasm32-unknown-unknown

FROM debian:bullseye-slim

RUN mkdir /artifacts

COPY --from=builder /usr/src/myapp/target/wasm32-unknown-unknown/release/*.wasm /artifacts/
COPY --from=builder /usr/src/myapp/target/wasm32-unknown-unknown/release/*.idl /artifacts/

ENTRYPOINT ["echo", "Artifacts published to /artifacts"]

0 comments on commit dc1591f

Please sign in to comment.