Dockerfile: db connection works out of Docker container.

pull/2/head
leonnicolas 4 years ago
parent bb96724bcd
commit 87fd338088
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -3,12 +3,13 @@ WORKDIR /
COPY ./src /src COPY ./src /src
COPY ./package*.json ./ COPY ./package*.json ./
COPY ./gulpfile.js ./tsconfig.json ./tslint.json ./ COPY ./gulpfile.js ./tsconfig.json ./
COPY ./ormconfig.json ./
RUN npm install RUN npm install
RUN npm install -g gulp RUN npm install -g gulp
RUN npm install gulp RUN npm install gulp
RUN gulp RUN gulp
EXPOSE 4000 EXPOSE 4000
EXPOSE 5432
CMD ["npm", "start"] CMD ["npm", "start"]

@ -2,10 +2,14 @@
Apollo server written in typescript that handles business logic. Apollo server written in typescript that handles business logic.
## Usage ## 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 ### Docker
```bash ```bash
docker build -t <image name> . docker build -t <image name> .
docker run --rm -p 4000:4000 <image name> docker run --rm --network="host" <image name>
``` ```
The Dockerfile is pretty stupid and could produce a smaller image, e.g. with multistage build. The Dockerfile is pretty stupid and could produce a smaller image, e.g. with multistage build.
### Compile and run ### Compile and run

@ -1,6 +1,6 @@
{ {
"type": "postgres", "type": "postgres",
"host": "localhost", "host": "127.17.42.1",
"port": 5432, "port": 5432,
"username": "apollo", "username": "apollo",
"database": "apollo_test", "database": "apollo_test",

Loading…
Cancel
Save