summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--docker/Dockerfile2
-rw-r--r--docker/docker-compose.yml19
-rw-r--r--src/main.rs8
-rw-r--r--src/serve.rs2
5 files changed, 21 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index bf03dee..d6dd248 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
**/*.rs.bk
.env
.spotify_token_cache.json
+docker/data
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 88e1cbc..15b712d 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -8,7 +8,7 @@
FROM debian as spotify_intersect
WORKDIR /srv/spotify_intersect
#COPY --from=build /app/target/release/spotify_intersect ./
-RUN apt-get update && apt-get -y install libssl-dev
+RUN apt-get update && apt-get -y install libssl-dev ca-certificates
COPY ./target/release/spotify_intersect ./
COPY .env /srv/spotify_intersect/.env
COPY Rocket.toml ./
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 43af83e..0481399 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -4,26 +4,33 @@ services:
image: spotify_intersect
container_name: spotify_intersect
ports:
- - 8085:8085
+ - 8085:8085
build:
context: ..
dockerfile: docker/Dockerfile
#environment:
networks:
- - database
- - hostnet
+ - database
+ - hostnet
depends_on:
- - track_db
+ - track_db
+ links:
+ - "track_db:db"
+ #volumes:
+ #- /etc/ssl/certs:/etc/ssl/certs:ro
# - zookeeper
track_db:
image: postgres
container_name: track_db
networks:
- - database
+ - database
+ ports:
+ - 5432:5432
environment:
POSTGRES_PASSWORD: example
- volumes: ./data:/var/lib/postgresql/data
+ volumes:
+ - ./data:/var/lib/postgresql/data
#track_db:
#image: noria
# build:
diff --git a/src/main.rs b/src/main.rs
index c6b7d86..b0bda1b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,12 +10,12 @@ use std::sync::{Arc, Mutex};
lazy_static! {
static ref CLIENT: Arc<Mutex<Client>> = Arc::new(Mutex::new(
- Client::connect("host=localhost user=postgres password=example", NoTls).unwrap()
+ Client::connect("host=track_db user=postgres password=example", NoTls).unwrap()
));
}
fn main() {
- //initialize_db().unwrap();
+ initialize_db().unwrap();
//setup_db().unwrap();
println!("connected with db");
rocket::ignite()
@@ -44,9 +44,11 @@ fn setup_db() -> Result<(), postgres::Error> {
fn initialize_db() -> Result<(), postgres::Error> {
let mut client = CLIENT.lock().unwrap();
+ let _ = client.batch_execute(
+ "DROP TABLE user_track; DROP TABLE suser; DROP TABLE track;"
+ );
client.batch_execute(
"
- DROP TABLE user_track; DROP TABLE suser; DROP TABLE track;
CREATE TABLE track (
track_id SERIAL PRIMARY KEY,
track_code TEXT NOT NULL UNIQUE,
diff --git a/src/serve.rs b/src/serve.rs
index 5696f12..babb3fe 100644
--- a/src/serve.rs
+++ b/src/serve.rs
@@ -100,7 +100,7 @@ pub fn get_tracks(name: String, url: String) -> String {
VALUES ($1, $2, $3)
ON CONFLICT
ON CONSTRAINT track_user_pkey
- DO UPDATE;",
+ DO NOTHING;",
&[&tid, &uid, &0],
)
.unwrap();