diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df499a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:12 +WORKDIR /usr/src/app +COPY . . +RUN yarn +EXPOSE 8080 +ENV NODE_ENV=production +CMD [ "yarn", "dev" ] \ No newline at end of file diff --git a/README.md b/README.md index fb202de..876dfb5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,18 @@ https://github.com/ide-stories/vscode-stories -# How to run on your computer +# How to run with docker (recommended, requires docker & docker-compose) +1. Make sure you have no services running on ports 5050, 8080 and 5432 (e.g. with `netstat -tulpn | grep LISTEN`). + If necessary, you can change the *ports* section of each service in the *docker-compose.yml*. +2. Set the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` variables in *docker-compose.yml*. +3. Run `docker-compose up -d` from the project root +4. Your stack is now running partially. Open pgAdmin on *localhost:5050* with the default credentials (*pgadmin4@gpadmin.org|admin*) + and create a server with host 'postgres_container', + username 'postgres', password 'changeme'. Create a database called *stories*. +5. Restart the api service with `docker-compose restart api` +6. Check with `docker-compose logs api` if the server is running. It should say *server started* +# How to run on your computer (native) 1. Have PostgreSQL running on your computer 2. Create a database called `stories` 3. Copy `.env.example` to `.env` and fill in `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` (you will have to register a GitHub OAuth account and set the callback url to: http://localhost:8080/auth/github/callback) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a0612f3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,61 @@ +version: '3.5' + +services: + + api: + container_name: stories_api + build: . + ports: + - 8080:8080 + + environment: + TOKEN_SECRET: jqowd0qwe012jjje21dojdol2io1dj12o + DB_HOST: postgres_container + DB_USER: postgres + DB_PASSWORD: changeme + DB_PORT: 5432 + GITHUB_CLIENT_ID: test + GITHUB_CLIENT_SECRET: test + SERVER_URL: 'localhost:8080' + REFRESH_TOKEN_SECRET: wqoikdjq90d210381jdwq0oe0192803e12ejmsakldjqowei12 + ACCESS_TOKEN_SECRET: woqieod12u09e8120eusaoidcnasjo0923810ued9j1n2oijaqwe + networks: + - postgres + restart: unless-stopped + + postgres: + container_name: postgres_container + image: postgres + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: changeme + PGDATA: /data/postgres + volumes: + - postgres:/data/postgres + ports: + - 5432:5432 + networks: + - postgres + restart: unless-stopped + + pgadmin: + container_name: pgadmin_container + image: dpage/pgadmin4 + environment: + PGADMIN_DEFAULT_EMAIL: pgadmin4@pgadmin.org + PGADMIN_DEFAULT_PASSWORD: admin + volumes: + - pgadmin:/root/.pgadmin + ports: + - 5050:80 + networks: + - postgres + restart: unless-stopped + +networks: + postgres: + driver: bridge + +volumes: + postgres: + pgadmin: \ No newline at end of file