IntersectMBO / cardano-transactions

Library utilities for constructing and signing Cardano transactions.
Apache License 2.0
25 stars 7 forks source link

Add Dockerfile #21

Closed hasufell closed 3 years ago

hasufell commented 3 years ago

See https://github.com/input-output-hk/cardano-transactions/issues/22 for discussion and decisions

hasufell commented 3 years ago

I have included a commit that adds a github workflow for building and pushing images to dockerhub. For that to actually work we'd need to:

  1. create a dedicated "machine" user on our dockerhub inputoutput organisation
  2. have devops manage the credentials
  3. create an API token on dockerhub for that user
  4. add the credentials to secrets in this repository settings (using the variable names DOCKERHUB_USERNAME and DOCKERHUB_TOKEN)

I think this is low-effort and should be tried out. Otherwise I'll remove the commit.

paweljakubas commented 3 years ago

I managed to produce image :

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker build --tag  cardano-transactions .
....
Removing intermediate container 576d47245b20
 ---> 450c03d71cea
Successfully built 450c03d71cea
Successfully tagged cardano-transactions:latest
pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
cardano-transactions       latest              450c03d71cea        8 minutes ago       4.04MB
<none>                     <none>              fba180810d28        8 minutes ago       4.1GB

Also was able to invoke the stuff:

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti 450c03d71cea empty 764824073
-----BEGIN CARDANO TX-----
version: 1.0.0
Gi2WSgmf/5//
-----END CARDANO TX-----

But had problem when adding the rest, for example:

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti 450c03d71cea empty 764824073 \
> | cardano-tx add-input 0 3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7
cardano-tx: command not found
write /dev/stdout: broken pipe

OR

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti 450c03d71cea empty 764824073 \
> | add-input 0 3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7
add-input: command not found
write /dev/stdout: broken pipe
paweljakubas commented 3 years ago

@hasufell maybe I am doing something wrong when running docker image? I also tried :

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti 450c03d71cea empty 764824073 \
> | docker run --rm -ti 450c03d71cea add-input 0 3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7
the input device is not a TTY
write /dev/stdout: broken pipe

Nevertheless, would be good to add instructions how to built and run an example in README.md

paweljakubas commented 3 years ago

Now works for me:

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti --entrypoint sh cardano-transactions
/ # cardano-tx empty 764824073 \
> | cardano-tx add-input 0 3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7 \
> | cardano-tx add-output 42 Ae2tdPwUPEZETXfbQxKMkMJQY1MoHCBS7bkw6TmhLjRvi9LZh1uDnXy319f \
> | cardano-tx lock \
> | cardano-tx sign-with e0860dab46f13e74ab834142e8877b80bf22044cae8ebab7a21ed1b8dc00c155f6b78eee2a5bbd453ce7e7711b2964abb6a36837e475271f18ff36ae5fc8af73e25db39fb78e74d4b53fb51776d0f5eb360e62d09b853f3a87ac25bf83
4ee1fb \
> | cardano-tx serialize
goOfggDYGFgkglggO0AmURHYuzw8YI2Vs6C/g0YazjLXkzZXmhk5s6rRwLcA/5+CgtgYWCGDWByw5pPLyXJyvUKqzztEPsrGi5a0+iAVkYako4iDoAAaSXwVxhgq/6CBggDYGFiFglhAjmICNbKkJyWcwaHGOvnvF5yztuOW2hguAdZd0+176UviXbOft4501LU/tRd20PXrNg5i0JuFPzqHrCW/g07h+1hANoRQGiE0a6PBmm3DR5GA6AoU5e3A/7SxRpq+AzLn4crykdUMuNLEfuN/a0S3+/zFobAbwmIDjpOWm5pyiis1AA==/ # ^C
/ # exit

@KtorZ @rvl so from my user perpective I confirm it works fine. I was able to build locally and use it. The image is very small 4.04mb which is awesome. When it comes to whether other parts (devops, deployment, etc) are correct/as should be I leave those considerations to you

paweljakubas commented 3 years ago

Now image doubled in size, although still very small:

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
cardano-tx                 latest              572c49fc00ee        3 minutes ago       8.38MB

Contener works:

pawel@pure:~/Work/IOHK/cardano-transactions (hasufell/ADP-290/create-docker-image)$ docker run --rm -ti --entrypoint sh cardano-tx
/ # cardano-tx empty 764824073 \
> | cardano-tx add-input 0 3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7 \
> | cardano-tx add-output 42 Ae2tdPwUPEZETXfbQxKMkMJQY1MoHCBS7bkw6TmhLjRvi9LZh1uDnXy319f \
> | cardano-tx lock \
> | cardano-tx sign-with e0860dab46f13e74ab834142e8877b80bf22044cae8ebab7a21ed1b8dc00c155f6b78eee2a5bbd453ce7e7711b2964abb6a36837e475271f18ff36ae5fc8af73e25db39fb78e74d4b53fb51776d0f5eb360e62d09b853f3a87ac25bf83
4ee1fb \
> | cardano-tx serialize
goOfggDYGFgkglggO0AmURHYuzw8YI2Vs6C/g0YazjLXkzZXmhk5s6rRwLcA/5+CgtgYWCGDWByw5pPLyXJyvUKqzztEPsrGi5a0+iAVkYako4iDoAAaSXwVxhgq/6CBggDYGFiFglhAjmICNbKkJyWcwaHGOvnvF5yztuOW2hguAdZd0+176UviXbOft4501LU/tRd20PXrNg5i0JuFPzqHrCW/g07h+1hANoRQGiE0a6PBmm3DR5GA6AoU5e3A/7SxRpq+AzLn4crykdUMuNLEfuN/a0S3+/zFobAbwmIDjpOWm5pyiis1AA==/ # 
/ # exit