Skip to content

Commit

Permalink
Add bindmount for static files in production
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshaughnessy committed Nov 7, 2023
1 parent 9fa600c commit adbeee5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Replace static files on server
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} 'bash -s' << 'ENDSSH'
mkdir -p /track/server/static/client
tar -xzvf /tmp/web-client.tar.gz -C /track/server/static/client --strip-components=1
mkdir -p ~/track/server/static/client
tar -xzvf /tmp/web-client.tar.gz -C ~/track/server/static/client --strip-components=1
rm /tmp/web-client.tar.gz
ENDSSH
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Alternatively, you can start the server with:
```sh
dc exec -it track-server bash

APP_ENV="development" cargo run --bin server
APP_ENV="dev" cargo run --bin server
```

And the client with
Expand Down
2 changes: 2 additions & 0 deletions docker/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ version: "3.1"
services:
track-server:
image: us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-server
volumes:
- ./track:/track
6 changes: 3 additions & 3 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ async fn main() -> std::io::Result<()> {

HttpServer::new(move || {
let cors = match app_env {
ref x if x == "development" => Cors::default()
ref x if x == "dev" => Cors::default()
.allow_any_origin()
.allowed_methods(vec!["GET", "POST", "PATCH", "DELETE"])
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600),
ref x if x == "production" => Cors::default()
ref x if x == "prod" => Cors::default()
.allowed_origin("https://www.example.com")
.allowed_methods(vec!["GET", "POST", "PATCH", "DELETE"])
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
.allowed_header(http::header::CONTENT_TYPE)
.max_age(3600),
_ => panic!("APP_ENV must be set to either 'development' or 'production'"),
_ => panic!("APP_ENV must be set to either 'dev' or 'prod'"),
};

println!("APP_ENV: {:?}", std::env::var("APP_ENV"));
Expand Down

0 comments on commit adbeee5

Please sign in to comment.