Skip to content

Commit

Permalink
Fix/dockerfile token server (#85)
Browse files Browse the repository at this point in the history
* fix: token server dockerfile

* fix: build release for token server

* fix: upgrade sqlx version
  • Loading branch information
DhananjayPurohit committed Aug 22, 2024
1 parent 79aa159 commit 5a451df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion token-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
config = "0.13.1"
reqwest = { version = "0.11.16", features = ["blocking", "json", "socks"] }
rocket = { version = "0.5.0-rc", features = ["json"] }
sqlx = { version = "0.7", features = [ "runtime-tokio", "postgres", "time", "uuid", "tls-rustls" ] }
sqlx = { version = "0.8.0", features = [ "runtime-tokio", "postgres", "time", "uuid", "tls-rustls" ] }
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
schemars = { version = "0.8.12", features = ["chrono", "uuid"] }
Expand Down
39 changes: 30 additions & 9 deletions token-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
FROM rust:1.77.0
# Use a base image that has the required GLIBC version
FROM debian:bullseye-slim as builder

# Set working directory
WORKDIR /app/lib
COPY ../lib .
# Install Rust, protobuf compiler, and library dependencies
RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler libprotobuf-dev pkg-config libssl-dev
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Copy the project code
WORKDIR /app
COPY . .
# Set the environment path for Rust
ENV PATH="/root/.cargo/bin:${PATH}"

# Create a working directory
WORKDIR /mercurylayer

RUN echo "[workspace]\nmembers = [\"token-server\", \"lib\"]" > ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock

# Copy the server source code
COPY ./token-server ./token-server
COPY ./lib ./lib
COPY ./Rocket.toml ./token-server/Rocket.toml

# Make sure to copy Cargo.lock
COPY ./token-server/Cargo.lock ./token-server/Cargo.lock

WORKDIR /mercurylayer/token-server

# RUN cargo build --verbose

# # Build your Rust project. Since the source files are now present,
# # the Rust compiler should be able to find and compile them.
RUN CARGO_TARGET_DIR=target cargo build --release

RUN cargo build --release
EXPOSE 8001
# Run the application
# # Command to run the token server by default when the container starts
CMD ["cargo", "run", "--bin", "token-server"]

0 comments on commit 5a451df

Please sign in to comment.