docker-compose_update - Updated docker-compose to be fully functional
I updated Dockerfile and docker-compose.yml to work together. Each component of the app can now be deployed at once.
This commit is contained in:
parent
91e92c112f
commit
f134f7e690
|
|
@ -3,12 +3,14 @@ WORKDIR ./app
|
|||
COPY . .
|
||||
RUN cargo install --path .
|
||||
|
||||
FROM debian:bookworm-slim as runner
|
||||
FROM rustlang/rust:nightly as runner
|
||||
COPY migrations /migrations
|
||||
RUN cargo install diesel_cli --no-default-features --features postgres
|
||||
RUN apt update && apt install -y libpq-dev libc6
|
||||
COPY --from=builder /usr/local/cargo/bin/request-mirror /usr/local/bin/request-mirror
|
||||
COPY ./templates /templates
|
||||
COPY .env.docker .env
|
||||
COPY .env.docker /.env
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
ENV ROCKET_ENV=production
|
||||
EXPOSE 8000
|
||||
CMD ["request-mirror"]
|
||||
ENTRYPOINT diesel migration run --migration-dir /migrations && request-mirror
|
||||
20
README.md
20
README.md
|
|
@ -4,16 +4,24 @@ This application provides a web ui for sending get/post requests and provides a
|
|||
## TODO:
|
||||
- Update Readme
|
||||
- Document
|
||||
- Setup Docker
|
||||
|
||||
## Docker
|
||||
|
||||
This is the current setup for getting the webapp to work with docker. This may not work on your machine, this is beta.
|
||||
Please read through the documentation on setting up and installing docker on your machine.
|
||||
We'll use the CLI commands to deploy the application to docker.
|
||||
|
||||
See [Get Docker](https://docs.docker.com/get-docker/)
|
||||
|
||||
First you'll want to ensure you have build the container. Do that by running
|
||||
|
||||
```bash
|
||||
cd request-mirror
|
||||
|
||||
sh deploy.sh
|
||||
docker build . -t raspberrypi99/request-mirror
|
||||
```
|
||||
|
||||
This will setup the container. A better setup will come in the future.
|
||||
Next you can start up the application using docker compose
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
This will deploy the application to docker. It will setup the postgres server, deploy the database using diesel and start request-mirror.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,6 @@
|
|||
version: 3.8
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
request-mirror:
|
||||
image: request-mirror
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
- DB_HOST=postgres
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
postgres:
|
||||
image: postgres
|
||||
environment:
|
||||
|
|
@ -22,6 +11,22 @@ services:
|
|||
- db-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- app-network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres -d request_mirror_db | grep 'accepting connections'"]
|
||||
request-mirror:
|
||||
#image: request-mirror
|
||||
build: &request_mirror_build
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
ports:
|
||||
- 80:8000
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:password@postgres/request_mirror_db
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
|
|
|
|||
|
|
@ -29,3 +29,5 @@ CREATE TABLE IF NOT EXISTS pair_records
|
|||
key TEXT NOT NULL,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX pair_records_history_id_idx ON pair_records(history_id);
|
||||
|
|
|
|||
14
src/lib.rs
14
src/lib.rs
|
|
@ -15,7 +15,10 @@ use schema::{
|
|||
/// Establishes diesel Postgres connection that can be used to iteract with the database
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// use request_mirror::establish_connection;
|
||||
///
|
||||
/// let connection = establish_connection();
|
||||
/// ```
|
||||
pub fn establish_connection() -> PgConnection {
|
||||
|
|
@ -30,10 +33,13 @@ pub fn establish_connection() -> PgConnection {
|
|||
/// Used to create a new client in the database. You need to pass a connection, the ip and client_id
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// let connection = establish_connection();
|
||||
///
|
||||
/// create_client(connection, "192.168.0.1", "195222-222-123123");
|
||||
/// ```rust,ignore
|
||||
/// use request_mirror::{establish_connection, create_client};
|
||||
///
|
||||
/// let mut connection = establish_connection();
|
||||
///
|
||||
/// create_client(&mut connection, "192.168.0.1", "195222-222-123123");
|
||||
/// ```
|
||||
///
|
||||
/// create_client returns a value of usize which represents the number of entries created
|
||||
|
|
|
|||
Loading…
Reference in New Issue