@@ -4,35 +4,44 @@ NAME = directory
44IMAGE = privatebin/$(NAME )
55PORT = 8000
66GEOIP_MMDB =var/geoip-country.mmdb
7+ DATABASE =var/directory.sqlite
8+ ROCKET_DATABASES="{directory={url =\"$(DATABASE ) \"}}"
79
810all : test build image run check clean # # Equivalent to "make test build image run check clean" (default).
911
1012release : test build pack image run check clean # # Equivalent to "make test build pack image run check clean".
1113
1214test : .cargo/registry # # Build and run the unit tests.
13- docker run --rm -t --init -e GEOIP_MMDB=" /home/rust/src/$( GEOIP_MMDB) " \
15+ docker run --rm -t --init \
16+ -e GEOIP_MMDB=" $( GEOIP_MMDB) " \
17+ -e ROCKET_DATABASES=" $( ROCKET_DATABASES) " \
1418 -v " $( CURDIR) " :/home/rust/src \
1519 -v " $( CURDIR) " /.cargo/registry:/home/rust/.cargo/registry \
16- ekidd/rust-musl-builder:nightly-2020-03-12 \
20+ ekidd/rust-musl-builder:nightly-2020-03-12-sqlite \
1721 cargo test --release # -- --nocapture
1822
1923build : .cargo/registry # # Build the binary for release.
20- docker run --rm -t --init -e GEOIP_MMDB=" /home/rust/src/$( GEOIP_MMDB) " \
24+ docker run --rm -t --init \
25+ -e GEOIP_MMDB=" $( GEOIP_MMDB) " \
26+ -e ROCKET_DATABASES=" $( ROCKET_DATABASES) " \
2127 -v " $( CURDIR) " :/home/rust/src \
2228 -v " $( CURDIR) " /.cargo/registry:/home/rust/.cargo/registry \
23- ekidd/rust-musl-builder:nightly-2020-03-12 \
29+ ekidd/rust-musl-builder:nightly-2020-03-12-sqlite \
2430 cargo build --release
2531
2632pack : # # Strips and compresses the binary to reduce it's size, only intended for the release.
2733 strip target/x86_64-unknown-linux-musl/release/directory
2834 upx --ultra-brute target/x86_64-unknown-linux-musl/release/directory
2935
3036image : # # Build the container image.
31- docker build --build-arg PORT=$(PORT ) --build-arg GEOIP_MMDB=" /$( GEOIP_MMDB) " -t $(IMAGE ) .
37+ docker build --build-arg PORT=$(PORT ) \
38+ --build-arg GEOIP_MMDB=" /$( GEOIP_MMDB) " \
39+ --build-arg ROCKET_DATABASES=' {directory={url="/' $(DATABASE ) ' "}}' \
40+ -t $(IMAGE ) .
3241
3342run : # # Run a container from the image.
3443 docker run -d --init --name $(NAME ) -p=$(PORT ) :$(PORT ) \
35- --read-only -v " $( CURDIR) " :/var:ro --restart=always $(IMAGE )
44+ --read-only -v " $( CURDIR) /var " :/var --restart=always $(IMAGE )
3645
3746check : # # Launch tests to verify that the service works as expected, requires a running container.
3847 @sleep 1
@@ -46,6 +55,7 @@ check: ## Launch tests to verify that the service works as expected, requires a
4655clean : # # Stops and removes the running container.
4756 docker stop $(NAME )
4857 docker rm $(NAME )
58+ git checkout $(DATABASE )
4959
5060help : # # Displays these usage instructions.
5161 @echo " Usage: make <target(s)>"
0 commit comments