adding docker deployment

This commit is contained in:
evanpelle
2024-08-13 07:34:07 -07:00
parent cdb7adaa82
commit 7af66be06d
4 changed files with 61 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
# Use an official Node runtime as the base image
FROM node:18
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build-prod
# Expose the port the app runs on
EXPOSE 3000
# Define the command to run the app
CMD [ "node", "dist/server/server.js" ]
+18
View File
@@ -0,0 +1,18 @@
version: '3'
services:
game-server:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- /etc/letsencrypt:/etc/letsencrypt
depends_on:
- game-server
-1
View File
@@ -7,7 +7,6 @@
"start:client": "webpack serve --open --node-env development", "start:client": "webpack serve --open --node-env development",
"start:server": "node --loader ts-node/esm --experimental-specifier-resolution=node src/server/Server.ts", "start:server": "node --loader ts-node/esm --experimental-specifier-resolution=node src/server/Server.ts",
"dev": "concurrently \"npm run start:client\" \"npm run start:server\"", "dev": "concurrently \"npm run start:client\" \"npm run start:server\"",
"build": "tsc",
"test": "jest" "test": "jest"
}, },
"devDependencies": { "devDependencies": {
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# Ensure you're authenticated with Google Cloud
gcloud auth configure-docker
# Build the new Docker image
docker build -t openfrontio .
# Tag the new image (use a version number or 'latest')
docker tag openfrontio gcr.io/[YOUR-PROJECT-ID]/openfrontio:latest
# Push the new image to Google Container Registry
docker push gcr.io/[YOUR-PROJECT-ID]/openfrontio:latest
# Update the GCE instance with the new container image
gcloud compute instances update-container openfrontio-instance \
--container-image us-central1-docker.pkg.dev/openfrontio/openfrontio:latest \
--zone=us-central1-a
echo "Deployment complete. New version should be live soon."