Skip to content

Commit 4c46708

Browse files
committed
Clean up and comment
1 parent 062eeb3 commit 4c46708

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ RUN apt-get update -y \
99
&& apt-get clean -y \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
# ENVIRONMENT equaling `production` is required for sqlx to run offline and migrate properly
1213
ENV ENVIRONMENT production
1314
COPY ./target/release/zero2prod .
15+
# Configuration files are copied over but will be overwritten by environment variables injected from the PaaS or server
1416
COPY ./configuration ./configuration
17+
COPY ./migrations ./migrations
1518
ENTRYPOINT ["./zero2prod"]
1619
EXPOSE 8080
1720

Dockerfile.dev

+2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ RUN apt-get update -y \
99
&& apt-get clean -y \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
# ENVIRONMENT equaling `production` is required for sqlx to run offline and migrate properly
1213
ENV ENVIRONMENT production
1314
COPY ./target/debug/zero2prod .
1415
COPY ./configuration ./configuration
16+
COPY ./migrations ./migrations
1517
ENTRYPOINT ["./zero2prod"]
1618
EXPOSE 8080

scripts/run.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ parent_path=$(
55
)
66
cd "$parent_path"
77

8-
NAME=zero2prod
9-
PORT=8080
10-
118
./build.sh $1
129

10+
docker compose up
11+
# docker compose logs -f --no-log-prefix api | bunyan
12+
# docker compose logs -f database
13+
14+
### Non Docker Compose version
15+
16+
# NAME=zero2prod
17+
# PORT=8080
18+
1319
# # Remove previous containers by getting the container id then stopping it
1420
# CONTAINER_ID=$(docker ps -a -q --filter ancestor=$NAME --format="{{.ID}}")
1521

1622
# # If CONTAINER_ID is set, then stop it, otherwise don't do anything
1723
# if [[ $CONTAINER_ID ]]; then
1824
# docker stop $CONTAINER_ID
1925
# fi
20-
21-
# Docker compose version of above, stopping containers
22-
# docker compose down --remove-orphans
23-
24-
# Run containers
25-
docker compose up
26-
# docker compose logs -f --no-log-prefix api | bunyan
27-
# docker compose logs -f database

src/routes/subscriptions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub async fn subscribe(form: Form<FormData>, pool: Data<PgPool>) -> HttpResponse
2828
if (insert_subscriber(&form, &pool).await).is_ok() {
2929
HttpResponse::Ok().finish()
3030
} else {
31-
HttpResponse::InternalServerError().body("Email already exists")
31+
HttpResponse::InternalServerError().body("Database Error")
3232
}
3333
}
3434

target/release/zero2prod

135 KB
Binary file not shown.

0 commit comments

Comments
 (0)