Created
January 20, 2023 13:15
-
-
Save iffy/bfecbfad83e5dfabd7dc242025841975 to your computer and use it in GitHub Desktop.
Fly.io example demonstrating libsodium use failure. Launch with `fly launch` and see the logs for the error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch("gc", "orc") | |
switch("d", "nimDebugDlOpen") | |
when defined(linux): | |
import os | |
switch("dynlibOverride", "libsodium") | |
switch("cincludes", "/usr/include") | |
switch("clibdir", "/usr/lib") | |
switch("passL", "-lsodium") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- Stage 1 -- # | |
FROM nimlang/nim:1.6.10-alpine@sha256:408ebac99ad2d170a59e7a09c10e82e7336cf71fa38c7a1322aaa598a54d32c2 as builder | |
WORKDIR /app | |
RUN apk update && apk add libsodium-static libsodium musl-dev | |
RUN nimble install -y libsodium | |
COPY . . | |
RUN nim c -o:testapp main.nim | |
RUN ls -al | |
# -- Stage 2 -- # | |
FROM alpine:3.13.12@sha256:16fd981ddc557fd3b38209d15e7ee8e3e6d9d4d579655e8e47243e2c8525b503 | |
WORKDIR /root/ | |
RUN apk update && apk add libressl3.1-libcrypto | |
COPY --from=builder /app/testapp /usr/local/bin/ | |
CMD ["/usr/local/bin/testapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/asynchttpserver | |
import std/asyncdispatch | |
import libsodium/sodium | |
proc main {.async.} = | |
# libsodium test | |
try: | |
echo "Attempting crypto_pwhash_str..." | |
echo crypto_pwhash_str("some text") | |
echo "ok" | |
except: | |
echo "Failed crypto_pwhash_str: ", getCurrentExceptionMsg() | |
# webserver to keep fly happy | |
var server = newAsyncHttpServer() | |
proc cb(req: Request) {.async.} = | |
let headers = {"Content-type": "text/plain; charset=utf-8"} | |
await req.respond(Http200, "Hello World", headers.newHttpHeaders()) | |
server.listen(Port(8080)) | |
while true: | |
if server.shouldAcceptRequest(): | |
await server.acceptRequest(cb) | |
waitFor main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment