FEATURE: Made Port dynamic with env variable

This commit is contained in:
nikurasu 2022-11-10 15:49:01 +01:00
parent 9e1d7feda5
commit 32a496599f
8 changed files with 19 additions and 8 deletions

1
.env.example Normal file
View file

@ -0,0 +1 @@
PORT=3000

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
node_modules
src/dist
dev/docker/stacks/main/assets
dev/docker/stacks/main/assets
.env

View file

@ -4,10 +4,9 @@ WORKDIR /app
COPY src/ ./src
COPY package.json ./
COPY yarn.lock ./
COPY .env.example ./.env
COPY assets /assets
COPY dev/shell/entrypoint.sh /entrypoint.sh
RUN yarn
RUN yarn clean
RUN yarn build-prod
RUN yarn && yarn clean && yarn build-prod
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]

View file

@ -1,9 +1,11 @@
version: '3'
services:
app:
image: nikurasukun/socialtree
image: git.oishi-ra.men/nikurasu/socialtree-js:latest
container_name: socialtree
environment:
PORT: 3000
volumes:
- ./assets:/app/assets/
ports:
- 80:3000
- 3000:3000

View file

@ -1 +1 @@
docker build -t git.oishi-ra.men/nikurasu/socialtree-js -f dev/docker/images/main/Dockerfile --no-cache .
docker build -t git.oishi-ra.men/nikurasu/socialtree-js:latest -f dev/docker/images/main/Dockerfile --no-cache .

View file

@ -15,6 +15,7 @@
"build-prod": "sass --style=compressed src/public/themes:src/dist/style"
},
"dependencies": {
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"express": "^4.18.2",
"js-yaml": "^4.1.0"

View file

@ -1,11 +1,13 @@
import express from 'express'
import yaml from 'js-yaml'
import fs from 'node:fs'
import * as dotenv from 'dotenv'
console.log('🔧 Configuring socialtree...')
dotenv.config()
const app = express()
const port = 3000
const port = process.env.PORT
const engine = 'ejs'
app.set('view engine', engine)

View file

@ -211,6 +211,11 @@ destroy@1.2.0:
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015"
integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==
dotenv@^16.0.3:
version "16.0.3"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07"
integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==
ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"