Skip to content

Commit

Permalink
Sm 1186 fix docker image (#706)
Browse files Browse the repository at this point in the history
## Type of change

- [x] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

## Objective

Fix missing shared object libraries error:

```bash
docker run --rm -it --platform linux/amd64 $ACR_URL/bws:main --help
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
```

## Code changes

- **crates/bws/Dockerfile:** x86_64 Linux stores some shared object
libraries in a `/lib64` directory. We were missing
`/lib64/ld-linux-x86-64.so.2`. This should handle dependencies for both
arches. Also moved the binary to `/bin` to allow for `--entrypoint=bws`
overriding, without having to specify the full path to the bin.


## Before you submit

- Please add **unit tests** where it makes sense to do so
  • Loading branch information
tangowithfoxtrot authored Apr 23, 2024
1 parent ee463ec commit 72a3b49
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/bws/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ RUN cargo build --release --bin bws

# Bundle bws dependencies
RUN mkdir /lib-bws
RUN ldd /app/target/release/bws | tr -s '[:blank:]' '\n' | grep '^/' | xargs -I % cp % /lib-bws
RUN mkdir /lib64-bws

RUN ldd /app/target/release/bws | tr -s '[:blank:]' '\n' | grep '^/lib' | xargs -I % cp % /lib-bws
RUN ldd /app/target/release/bws | tr -s '[:blank:]' '\n' | grep '^/lib64' | xargs -I % cp % /lib64-bws

# Make a HOME directory for the app stage
RUN mkdir -p /home/app
Expand All @@ -35,15 +38,16 @@ LABEL com.bitwarden.product="bitwarden"
# Set a HOME directory
COPY --from=build /home/app /home/app
ENV HOME=/home/app
WORKDIR /home/app

# Copy built project from the build stage
WORKDIR /usr/local/bin
COPY --from=build /app/target/release/bws .
COPY --from=build /app/target/release/bws /bin/bws

# Copy certs
COPY --from=build /etc/ssl/certs /etc/ssl/certs

# Copy bws dependencies
COPY --from=build /lib-bws /lib
COPY --from=build /lib64-bws /lib64

ENTRYPOINT ["bws"]

0 comments on commit 72a3b49

Please sign in to comment.