Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #73

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ logs
certs
cdn
node_modules
*.yaml
*.yml
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ typings/
config.json
certs
cdn
dist
dist
*.yaml
*.yml
data
datastore
69 changes: 69 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Setup using Docker

## Overview
To use this, you must have Docker installed on your system. Please follow a tutorial elsewhere.

After performing the following steps, you will have the following running containers:
- mongodb (the database)
- account (the account server itself)

## Building the image
Use the following command to build the image:
```bash
$ docker build -t account .
```

## Running Using `docker run`
Create a `.env` file with all of the environment variables set. The list of variables can be found in [SETUP.md](SETUP.md).

Use a command similar to the following:
```bash
$ docker run --name mongodb -d -p 27017:27017 -e MONGODB_INITDB_ROOT_USERNAME=user -e MONGODB_INITDB_ROOT_PASSWORD=pass -v $(pwd)/data:/data/db mongo
$ docker run --name account -d -p 7070:7070 -p 7071:7071 -v $(pwd)/cdn:/app/cdn --env-file .env account
```

## Running Using `docker compose`
This is an example `docker-compose.yaml` file that will set up the containers, configure them, and launch them:

```yaml
services:
mongodb:
image: mongo
container_name: mongodb
ports:
- "27017:27017"
environment:
MONGODB_INITDB_ROOT_USERNAME: "user"
MONGODB_INITDB_ROOT_PASSWORD: "pass"
volumes:
- "${PWD}/data:/data/db"
networks:
- pretendo_web
account:
image: account
container_name: account
ports:
- "7070:7070"
- "7071:7071"
environment:
PN_ACT_PREFER_ENV_CONFIG: "true"
PN_ACT_CONFIG_HTTP_PORT: "7070"
PN_ACT_CONFIG_MONGO_CONNECTION_STRING: "mongodb://mongodb:27017/pretendo"
PN_ACT_CONFIG_CDN_BASE_URL: "http://pretendoacct.local"
PN_ACT_CONFIG_CDN_SUBDOMAIN: "cdn"
PN_ACT_CONFIG_CDN_DISK_PATH: "./cdn"
PN_ACT_CONFIG_WEBSITE_BASE: "https://example.com"
PN_ACT_CONFIG_AES_KEY: "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
PN_ACT_CONFIG_GRPC_MASTER_API_KEY_ACCOUNT: "apikey"
PN_ACT_CONFIG_GRPC_MASTER_API_KEY_API: "apikey"
PN_ACT_CONFIG_GRPC_PORT: "7071"
volumes:
- "${PWD}/cdn:/app/cdn"
networks:
- pretendo_web

networks:
pretendo_web:
driver: bridge
attachable: true
```
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
FROM node:18-alpine
FROM node:20.4.0-alpine3.18

RUN apk add --no-cache python3 make gcc g++
WORKDIR /app

COPY "docker/entrypoint.sh" ./

COPY package*.json ./
RUN npm install bcrypt && npm rebuild bcrypt --build-from-source
RUN npm install

COPY . ./
jonbarrow marked this conversation as resolved.
Show resolved Hide resolved
RUN npm run build

VOLUME [ "/app/config.json", "/app/certs" ]

CMD ["sh", "entrypoint.sh"]
CMD npm start
3 changes: 3 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Setup

- [Docker](#docker)
- [Required software](#required-software)
- [NodeJS](#nodejs)
- [MongoDB](#mongodb)
Expand All @@ -11,6 +12,8 @@
- [CDN](#cdn)
- [Configuration](#configuration)

## Docker
If using Docker, please see [DOCKER.md](DOCKER.md) for setup instructions.

## Required software

Expand Down
28 changes: 0 additions & 28 deletions docker/entrypoint.sh

This file was deleted.