Skip to content

Commit 1aa5822

Browse files
committed
Auto merge of #3053 - nilslice:sm/docker-run-fix, r=jtgeibel
dev: update docker node version, server address, and docker-compose Fixes dockerized environment to run crates.io locally.
2 parents deff144 + 324bf5e commit 1aa5822

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version: "3"
2+
23
services:
34
postgres:
45
image: postgres:9.6
@@ -10,16 +11,19 @@ services:
1011
- 5432:5432
1112
volumes:
1213
- postgres-data:/var/lib/postgresql/data
14+
1315
backend:
1416
build:
1517
context: .
1618
dockerfile: backend.Dockerfile
1719
environment:
20+
DEV_DOCKER: "true"
1821
DATABASE_URL: postgres://postgres:password@postgres/cargo_registry
1922
SESSION_KEY: badkeyabcdefghijklmnopqrstuvwxyzabcdef
2023
GIT_REPO_URL: file://./tmp/index-bare
2124
GH_CLIENT_ID: ""
2225
GH_CLIENT_SECRET: ""
26+
WEB_ALLOWED_ORIGINS: http://localhost:8888,http://localhost:4200
2327
links:
2428
- postgres
2529
ports:
@@ -32,6 +36,7 @@ services:
3236
- index:/app/tmp
3337
- cargo-cache:/usr/local/cargo/registry
3438
- target-cache:/app/target
39+
3540
frontend:
3641
build:
3742
context: .

docs/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ services:
528528
GH_CLIENT_SECRET: blahblah_secret
529529
```
530530

531+
These environment variables can also be defined in a local `.env` file, see `.env.sample`
532+
for various configuration options.
533+
531534
#### Accessing services
532535

533536
By default, the services will be exposed on their normal ports:

frontend.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12.9-alpine
1+
FROM node:14.9-alpine
22

33
WORKDIR /app
44
COPY package.json yarn.lock /app/

src/bin/server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6060

6161
let heroku = dotenv::var("HEROKU").is_ok();
6262
let fastboot = dotenv::var("USE_FASTBOOT").is_ok();
63+
let dev_docker = dotenv::var("DEV_DOCKER").is_ok();
6364

65+
let ip = if dev_docker {
66+
[0, 0, 0, 0]
67+
} else {
68+
[127, 0, 0, 1]
69+
};
6470
let port = if heroku {
6571
8888
6672
} else {
@@ -103,7 +109,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
103109
async move { Service::from_blocking(handler, addr) }
104110
});
105111

106-
let addr = ([127, 0, 0, 1], port).into();
112+
let addr = (ip, port).into();
107113
#[allow(clippy::async_yields_async)]
108114
let server = rt.block_on(async { hyper::Server::bind(&addr).serve(make_service) });
109115

0 commit comments

Comments
 (0)