Skip to content

Commit

Permalink
fix(workspace): create docker compose file and configurize api host a…
Browse files Browse the repository at this point in the history
…nd port
  • Loading branch information
lauhon committed Jun 16, 2023
1 parent a4500e5 commit 3686c9e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
API_HOST=localhost
API_PORT=3000
COOKIE_SECRET="our-secure-cookie-secret"
LOG_LEVEL=debug
DB_URL=file:./db.sqlite
Expand Down
2 changes: 1 addition & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN turbo prune --scope=@superlight-labs/api --docker


# Install Dependencies and Node Modules
FROM amd64/node:16-bullseye-slim AS installer
FROM amd64/node:16 AS installer

RUN apt-get update
RUN apt-get --yes install python3 \
Expand Down
3 changes: 2 additions & 1 deletion apps/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import config from '@lib/config';
import { client } from '@superlight-labs/database';
import logger from '@superlight-labs/logger';
import { createServer } from 'src/server';

createServer(client)
.then(server => {
server.listen({ port: 8080 }, (err, address) => {
server.listen({ host: config.host, port: config.port }, (err, address) => {
if (err) {
logger.error({ err, address }, 'Error while trying to listen on port 8080');
process.exit(1);
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { config as loadConfig } from 'dotenv';
interface Config {
cookieSecret: string;
logLevel: string;
host: string;
port: number;
}

const initConfig = (): Config => {
Expand All @@ -11,6 +13,8 @@ const initConfig = (): Config => {
return {
cookieSecret: process.env.COOKIE_SECRET || '',
logLevel: process.env.LOG_LEVEL || 'debug',
host: process.env.API_HOST || '0.0.0.0',
port: parseInt(process.env.API_PORT || '3000', 10),
};
};

Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.8"

services:
api:
build:
context: .
dockerfile: ./apps/api/Dockerfile
ports:
- ${API_PORT}:${API_PORT}
environment:
- API_HOST=${API_HOST}
- API_PORT=${API_PORT}
- COOKIE_SECRET=${COOKIE_SECRET}
- LOG_LEVEL=${LOG_LEVEL}
- DB_URL=${DB_URL}
- TATUM_TEST_TOKEN=${TATUM_TEST_TOKEN}
- TATUM_MAIN_TOKEN=${TATUM_MAIN_TOKEN}
domainname: "${API_DOMAIN_NAME}"

0 comments on commit 3686c9e

Please sign in to comment.