Giter VIP home page Giter VIP logo

workerd-docker's Introduction

workerd-docker

A simple URL shortener implemented using Workers (workerd) running in Docker/Kubernetes.

See this blog post for some details.

Forked and modifed sample from https://github.com/WalshyDev/workerd-example

Running

To run simply install the dependencies and run workerd :)

Requests are served at http://localhost:8080 (can be changed in config.capnp). Update UPSTASH_REDIS_REST_TOKEN and UPSTASH_REDIS_REST_URL to your Upstash redis details, or to any Redis server credentials with a different provider.

# Install the dependencies (including workerd)
npm i

# Bundle your Worker and start Workerd serving the Worker
npm run dev

Building Docker Image

npm run build

docker build . -t redirect

# Run the image
docker run -d --rm -p 49160:8080 redirect

Testing

Once the Worker is running we can test it!

To create a redirect do a POST to /create like so:

$ curl -X POST -d '{"slug": "test", "destination": "https://pmbanugo.me"}' http://localhost:8080/create

Then to test the redirect simply send a GET request to the slug like so:

$ curl -i http://localhost:8080/test
HTTP/1.1 302 Found
Content-Length: 0
Location: https://pmbanugo.dev

workerd-docker's People

Contributors

dependabot[bot] avatar pmbanugo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

workerd-docker's Issues

error while loading shared libraries: libunwind.so.1

Hi!

Thanks for this great example repo!

Looks like workerd has been updated recently and now needs one more library:

/usr/src/app/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd: error while loading shared libraries: libunwind.so.1: cannot open shared object file: No such file or directory
node:child_process:910
    throw err;
    ^

Error: Command failed: /usr/src/app/node_modules/@cloudflare/workerd-linux-arm64/bin/workerd serve config.capnp --verbose
    at checkExecSyncError (node:child_process:871:11)
    at Object.execFileSync (node:child_process:907:15)
    at Object.<anonymous> (/usr/src/app/node_modules/workerd/bin/workerd:134:26)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  status: 127,
  signal: null,
  output: [ null, null, null ],
  pid: 96,
  stdout: null,
  stderr: null
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.