From bb70a968581ae675284aaae9231a0c189bdcb08d Mon Sep 17 00:00:00 2001 From: franklinblanco Date: Wed, 13 Jul 2022 00:07:19 -0400 Subject: [PATCH] made changes to the dockerfile --- Dockerfile | 18 ++++++++---------- sql/schema/user/find_with_email.sql | 2 +- sql/schema/user/insert.sql | 2 +- src/dao/main_dao.rs | 10 +++++++++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 891a155..e0d668a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,11 @@ +# 1. This tells docker to use the Rust official image FROM rust:1.62 + +# 2. Copy the files in your machine to the Docker image +COPY ./ ./ -WORKDIR /usr/src/user-svc - -COPY . . - +# Build your program for release RUN cargo build --release - -COPY ./target/release/user-svc-actix . - -RUN rm -r `ls | grep -v "user-svc-actix"` - -CMD ["user-svc-actix"] \ No newline at end of file + +# Run the binary +CMD ["./target/release/user-svc-actix"] \ No newline at end of file diff --git a/sql/schema/user/find_with_email.sql b/sql/schema/user/find_with_email.sql index d682909..a9b92cc 100644 --- a/sql/schema/user/find_with_email.sql +++ b/sql/schema/user/find_with_email.sql @@ -1,4 +1,4 @@ SELECT * FROM user WHERE user.email = ? AND -app = ? \ No newline at end of file +user.app = ? \ No newline at end of file diff --git a/sql/schema/user/insert.sql b/sql/schema/user/insert.sql index 884f59e..cd2bb7f 100644 --- a/sql/schema/user/insert.sql +++ b/sql/schema/user/insert.sql @@ -1,3 +1,3 @@ INSERT INTO user -(id, time_created, last_updated, email, app, name, password, salt) values +(id, time_created, last_updated, app, email, name, password, salt) values (NULL, NOW(), NOW(), ?, ?, ?, ?, ?) \ No newline at end of file diff --git a/src/dao/main_dao.rs b/src/dao/main_dao.rs index af26feb..c769380 100644 --- a/src/dao/main_dao.rs +++ b/src/dao/main_dao.rs @@ -20,7 +20,15 @@ pub async fn start_database_connection(env_vars: &HashMap) -> Re None => panic!("DB_DATABASE_NAME env var not found") }; let formatted_db_url = &format!("mysql://{db_user}:{db_pass}@{db_host}/{db_database_name}"); - sqlx::MySqlConnection::connect(&formatted_db_url).await + let mut rs = sqlx::MySqlConnection::connect(&formatted_db_url).await; + for _i in 1..20 { + match &rs { + Ok(_conn) => {break;}, + Err(_e) => {} + } + rs = sqlx::MySqlConnection::connect(&formatted_db_url).await; + } + rs } pub async fn run_all_migrations(conn: &mut MySqlConnection){ match sqlx::migrate!("./migrations").run(conn).await {