Skip to content

Commit

Permalink
Merge pull request #4 from weareseba/feature/docker
Browse files Browse the repository at this point in the history
adding a dockerfile to run it
  • Loading branch information
ulrichard authored Oct 5, 2023
2 parents 0528021 + 131c762 commit 3f3e2d7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
.git/
.github/
Dockerfile
Makefile
36 changes: 8 additions & 28 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,14 @@ jobs:
- name: Test
run: cargo test


# check-azure:
# name: Check Azure
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Cache
# uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# target
# key: ${{ runner.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
# - run: sudo apt-get update || exit 1
# - run: sudo apt-get install -y clang musl musl-tools || exit 1
# - run: sudo ln -s /usr/bin/g++ /usr/bin/musl-g++
# - name: Set default toolchain
# run: rustup default 1.63.0
# - name: Set profile
# run: rustup set profile minimal
# - name: Add target musl
# run: rustup target add x86_64-unknown-linux-musl
# - name: Update toolchain
# run: rustup update
# - name: Check
# run: cargo build --release --target=x86_64-unknown-linux-musl
build-docker:
name: build docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build the Docker image
run: docker build --file Dockerfile --tag bdk-reserves-web .

fmt:
name: Rust fmt
Expand Down
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ bdk = "0.28"
bdk-reserves = "0.28"
env_logger = "0.10"
log = "0.4"
base64 = "^0.13"
base64 = "0.13"

[dev-dependencies]
actix-rt = "1"
actix-rt = "1"

[profile.release]
opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
strip = true # Strip symbols from binary*
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM rust:1.72-alpine3.18 as builder
RUN apk add --no-cache build-base
USER bin
WORKDIR /app
COPY . .
RUN cargo test
RUN cargo build --release
RUN install -D target/release/bdk-reserves-web dist/bin/bdk-reserves-web
RUN ldd dist/bin/bdk-reserves-web | tr -s [:blank:] '\n' | grep ^/ | xargs -I % install -D % dist/%
RUN ln -s ld-musl-x86_64.so.1 dist/lib/libc.musl-x86_64.so.1

RUN rustup component add clippy-preview \
&& rustup component add rustfmt
RUN cargo install cargo-audit
RUN cargo fmt -- --check
RUN cargo clippy
#RUN cargo audit

FROM scratch
COPY --from=builder /app/dist /
USER 65534
ENTRYPOINT ["/bin/bdk-reserves-web"]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TAG := bdk-reserves-web

run: builder
docker run --rm --tty --env PORT=8888 --publish 8888:8888 ${TAG}

builder:
docker build --tag ${TAG} .

0 comments on commit 3f3e2d7

Please sign in to comment.