Skip to content

Commit f00380c

Browse files
committed
Moar automation for codespaces!
1 parent 9542d0d commit f00380c

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
66
&& apt-get -y install clang lld \
77
&& apt-get autoremove -y && apt-get clean -y \
88
&& cargo install --no-default-features -F postgres,rustls sqlx-cli
9+
10+
RUN mkdir -p /root/.local/bin/ && curl -s -o /root/.local/bin/mc \
11+
https://dl.min.io/client/mc/release/linux-amd64/mc \
12+
&& chmod 755 /root/.local/bin/mc

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,19 @@ prepare:
4545
.PHONY: migrate
4646
migrate:
4747
cargo sqlx migrate run
48+
49+
# Generate config.toml
50+
.PHONY: bucket
51+
bucket:
52+
@echo "Configuring minio client..."
53+
mc alias set --quiet mc "http://127.0.0.1:9000" "minioadmin" "minioadmin"
54+
@echo "Creating bucket..."
55+
mc mb --region global --ignore-existing --quiet mc/pastebin
56+
@echo "Setting up access key..."
57+
mc admin accesskey create \
58+
--access-key '<s3 access key!>' \
59+
--secret-key '<s3 secret key!>' \
60+
--policy confs/s3/key-policy.json mc/
61+
@echo "Configuring anonymous access..."
62+
mc anonymous set download mc/pastebin
63+
@echo "Configuration complete"

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ Building and running the thing has a few requirements:
2020
* Be signed into GitHub and click on the green `Code` button in the top right corner of the repository
2121
* Select Codespaces tab and click on the `Create codespace`
2222
* Let the thing wriggle and build for a bit! It takes a while for the first time
23-
* Click on forwarded ports and open the address for port 9001 in your browser
24-
* Input `minioadmin` for username and password in it!
25-
* Make a new bucket called `pastebin` in there and copy `confs/s3/bucket-policy.json` into its custom access policy
26-
* Make a new key in there and copy `confs/s3/key-policy.json` into its user policy, make sure to note down the access key and secret key!
27-
* Copy config.toml.sample to a file called config.toml and edit for correct values
23+
* Copy config.toml.sample to a file called config.toml
2824
* The codespace domain for port 2024 goes in `static_domain` in config.toml
2925
* The codespace address+`pastebin/` for port 9000 goes in `s3_bucket_url` in config.toml
30-
* Fill in the `aws_access_key_id` and `aws_secret_access_key` generated above
26+
* Open the terminal and type `make bucket` -- run this only once!
3127
* Open the terminal and type `make migrate`, `make check`, and then `make run`
32-
* Make the forward address for port 9000 public in the codespace!
28+
* Make the forward address for port 9000 public in the codespace
3329
* Open the address for the forwarded port 2024 in your browser!
3430
* Tada! You have a working pastebin!
3531

confs/nginx/02-korb.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ server {
3737
}
3838

3939
location /pastebin/content/ {
40+
limit_except GET OPTIONS {
41+
deny all;
42+
}
43+
4044
proxy_redirect off;
4145
proxy_http_version 1.1;
4246
proxy_set_header Host $host;

0 commit comments

Comments
 (0)