-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM rust:1.54 AS builder | ||
|
||
ARG DATABASE_URL | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY . . | ||
|
||
RUN cargo build --release | ||
|
||
RUN cargo install diesel_cli --no-default-features --features postgres | ||
RUN diesel migration run | ||
|
||
FROM debian:buster AS runner | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apt-get update -y && apt-get install -y libssl1.1 libpq5 | ||
|
||
COPY --from=builder /usr/src/app/target/release/haas_api . | ||
COPY --from=builder /usr/src/app/rocket.toml . | ||
COPY --from=builder /usr/src/app/openapi/openapi.yaml ./openapi/openapi.yaml | ||
|
||
CMD ["./haas_api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
# api | ||
# Hack as a Service API | ||
|
||
## Running locally | ||
|
||
1. Install [Docker](https://docker.com) and Docker Compose. | ||
2. Run `docker-compose up -d` to start up your development instance. | ||
3. Run `docker-compose exec main diesel migration run` to update the database (you only need to run this once, unless you modify the database schema) | ||
4. Visit http://localhost:3000 | ||
|
||
Other commands: | ||
|
||
- `docker-compose logs -f main` streams logs from the Rocket app | ||
- `docker-compose exec db psql -U postgres` opens a shell into the PostgreSQL database | ||
- `docker-compose stop` stops the dev environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM rust:1.54 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY . . | ||
|
||
RUN cargo install diesel_cli --no-default-features --features postgres && \ | ||
cargo install cargo-watch | ||
|
||
# Dummy build to fetch/compile dependencies | ||
RUN cargo build | ||
|
||
CMD ["cargo", "watch", "-x", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: "3" | ||
services: | ||
main: | ||
build: | ||
context: . | ||
dockerfile: dev.Dockerfile | ||
volumes: | ||
- .:/usr/src/app | ||
environment: | ||
ROCKET_DATABASES: '{db = {url = "postgres://postgres:postgres@db:5432/postgres"}}' | ||
DATABASE_URL: postgres://postgres:postgres@db:5432/postgres | ||
ports: | ||
- 3000:3000 | ||
db: | ||
image: postgres:alpine | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
volumes: | ||
- db_volume:/var/lib/postgresql/data | ||
volumes: | ||
db_volume: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[default] | ||
address = "0.0.0.0" | ||
port = 3000 | ||
|
||
[global.databases] | ||
|