Protohackers server programming challenge answers.
- install 'flyctl';
- authenticate;
- navigate to the root of the repository;
- allocate dedicated IPv4 address (costs $2/mo):
flyctl ips allocate-v4 --app <app name>
; - deploy:
flyctl deploy --dockerfile Dockerfile.<problem name> --ha=false
;- see problem names under
cmd/
directory and here;
- see problem names under
- find out currently allocated IP:
flyctl ips list
.
Important
Any uncommitted changes will also be deployed.
-
move to problem directory:
pushd cmd/<problem name>/
-
run tests:
go test -v === RUN TestProblem --- PASS: TestProblem (0.00s) PASS ok github.com/usrme/protohackers/cmd/<problem name> 3.138s
-
move back to the root of the repository:
popd
; -
build image:
docker build --tag <problem name> -f Dockerfile.<problem name> .
; -
run container:
docker run -p 5000:5000 <problem name>
; -
pass command:
$ echo "hello world" | nc -w1 localhost 5000 hello world
-
pass command:
$ echo "hello world" | nc -w1 <app name>.fly.dev 5000 hello world
Note
For testing in the Protohackers page, use the IP from flyctl ips list
and pass the port 5000