Add makefile for server and related action build test
Some checks failed
DRB Build Tests / build (push) Failing after 7s
DRB Build Tests / drb_build_and_test (push) Failing after 58s

This commit is contained in:
Logan Cusano
2024-04-28 04:46:08 -04:00
parent 63ccfa70d3
commit 49e52d8944
2 changed files with 23 additions and 11 deletions

View File

@@ -13,7 +13,7 @@ env:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: drb
SERVER_PORT: 6000
SERVER_PORT: 3000
MONGO_URL: "mongodb://mongodb:27017/drb"
TEST_GUILD_ID: ${{ secrets.TEST_GUILD_ID }}
TEST_CLIENT_TOKEN: ${{ secrets.TEST_CLIENT_TOKEN }}
@@ -36,16 +36,8 @@ jobs:
with:
node-version: '20'
- name: Install dependencies
working-directory: './server'
run: npm install
- name: Build Docker image
working-directory: './server'
run: docker build -t DRB-Server .
- name: Run Docker container
run: docker run -d --name drb -p 3000:3000 DRB-Server
- name: Build Docker image and run container
run: make build && make run
- name: Wait for server to start
run: sleep 10

20
server/makefile Normal file
View File

@@ -0,0 +1,20 @@
# Define variables
DOCKER_IMAGE_NAME := drb-server
# Define targets and rules
.PHONY: build run
build:
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE_NAME) ./server
run:
@echo "Running Docker container..."
docker run -e NODE_ENV=${NODE_ENV} \
-e MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} \
-e MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} \
-e MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} \
-e SERVER_PORT=${SERVER_PORT} \
-e MONGO_URL=${MONGO_URL} \
-p ${SERVER_PORT}:${SERVER_PORT} \
$(DOCKER_IMAGE_NAME)