Skip to content

Commit

Permalink
Merge pull request #278 from IntersectMBO/paweljakubas/docker-fix
Browse files Browse the repository at this point in the history
Docker fix
  • Loading branch information
paweljakubas authored Nov 8, 2024
2 parents dd665e6 + 49b6461 commit b170724
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ core/test/golden/*/actual
result*
.stack-to-nix.cache
.nix-shell-cabal.project
tmp/
41 changes: 11 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
# #
# --------------------------------- BUILD ------------------------------------ #
# #
# # Final image is based on scratch. We copy a bunch of Nix dependencies
# # but they're fully self-contained so we don't need Nix anymore.
FROM alpine:latest

FROM haskell:8.6.5 as build
WORKDIR /build
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential=12.3 \
git=1:2.11.*
RUN stack upgrade --binary-version 2.1.3
WORKDIR /app

# Leverage Docker cache, build in three steps: 1) snapshot, 2) deps, 3) app
COPY stack.yaml .
RUN mkdir -p command-line core
COPY core/package.yaml core/package.yaml
COPY command-line/package.yaml command-line/package.yaml
ADD jsbits /build/jsbits
RUN stack setup
RUN stack build --only-snapshot
RUN stack build --only-dependencies
COPY . .
RUN stack install --flag cardano-addresses:release
# Copy /nix/store
COPY ./tmp /nix/store
COPY ./tmp/cardano-address /app

# #
# ---------------------------------- RUN ------------------------------------- #
# #

FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.30
RUN apk add --no-cache gmp=6.1.2-r1 bash=5.0.11-r1 bash-completion=2.9-r0 libstdc++=9.3.0-r0
COPY --from=build /root/.local/bin /bin
RUN mkdir /etc/bash_completion.d
RUN cardano-address --bash-completion-script `which cardano-address` > /etc/bash_completion.d/cardano-address
RUN /app/cardano-address --bash-completion-script `which /app/cardano-address` > /etc/bash_completion.d/cardano-address
RUN echo "source /etc/bash_completion.d/cardano-address" >> ~/.bashrc
RUN echo "cardano-address --help" >> ~/.bashrc
ENTRYPOINT ["cardano-address"]
RUN echo "/app/cardano-address --help" >> ~/.bashrc

ENTRYPOINT ["/app/cardano-address"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,12 @@ $ cardano-address key public --without-chain-code < key.xsk | cardano-address ke

## Docker Image

Please make sure you have [just](https://github.com/casey/just) installed as `justfile` is used for building Docker image

### Build

```console
$ docker build -t cardano-address .
$ just clean-build-docker
```

### Run
Expand Down
1 change: 0 additions & 1 deletion core/test/Cardano/Address/Style/ShelleySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,6 @@ goldenTestGovernance GoldenTestGovernance{..} =
let coldXPrv = deriveCCColdPrivateKey acctXPrv
let coldXPrvTxt = bech32With CIP5.cc_cold_xsk $ getExtendedKeyAddr coldXPrv
let coldXPrvTxtHex = tob16text . unAddress $ getExtendedKeyAddr coldXPrv
let coldXPrvTxt = bech32With CIP5.cc_cold_xsk $ getExtendedKeyAddr coldXPrv
let coldPrvTxt = bech32With CIP5.cc_cold_sk $ getPrivateKeyAddr coldXPrv
let coldPrvTxtHex = T.decodeUtf8 $ encode EBase16 $ unAddress $ getPrivateKeyAddr coldXPrv
let coldXPubTxt = bech32With CIP5.cc_cold_xvk $ getPublicKeyAddr $ toXPub <$> coldXPrv
Expand Down
26 changes: 26 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# shellcheck shell=bash

LC_ALL := 'C.UTF-8'

default:
@just --list

# check that the code is properly linted
hlint:
nix develop --command hlint .

# build the docker image
build-docker:
nix build .
mkdir -p tmp
chmod +w -R tmp
rm -rf ./tmp/*
# shellcheck disable=SC2046
cp -R $(nix-store -qR result/) tmp
cp -L ./result/bin/cardano-address ./tmp/cardano-address
docker build . -t cardano-address

# build after clean
clean-build-docker:
cabal clean
just build-docker

0 comments on commit b170724

Please sign in to comment.