From 87fd338088c5e8d0afdc473965f1346bcd1950b9 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Fri, 11 Sep 2020 18:41:03 +0200 Subject: [PATCH] Dockerfile: db connection works out of Docker container. --- Dockerfile | 5 +++-- README.md | 6 +++++- ormconfig.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b83fbf7..6b03e8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,13 @@ WORKDIR / COPY ./src /src COPY ./package*.json ./ -COPY ./gulpfile.js ./tsconfig.json ./tslint.json ./ - +COPY ./gulpfile.js ./tsconfig.json ./ +COPY ./ormconfig.json ./ RUN npm install RUN npm install -g gulp RUN npm install gulp RUN gulp EXPOSE 4000 +EXPOSE 5432 CMD ["npm", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 85bb912..1eef3b9 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,14 @@ Apollo server written in typescript that handles business logic. ## Usage +### Configure Postgres +Install postgresql and configure it, so the Database is accessible from remote hosts (only necessary for docker container [Here](https://wiki.archlinux.org/index.php/PostgreSQL)) + +See postgres client config in __ormconfig.json__ ### Docker ```bash docker build -t . -docker run --rm -p 4000:4000 +docker run --rm --network="host" ``` The Dockerfile is pretty stupid and could produce a smaller image, e.g. with multistage build. ### Compile and run diff --git a/ormconfig.json b/ormconfig.json index 1fa2192..250b347 100644 --- a/ormconfig.json +++ b/ormconfig.json @@ -1,6 +1,6 @@ { "type": "postgres", - "host": "localhost", + "host": "127.17.42.1", "port": 5432, "username": "apollo", "database": "apollo_test",