diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d74977628 --- /dev/null +++ b/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..e9cb94d28 --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/package.json b/package.json index 26009390a..511ef8099 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "start:client": "webpack serve --open --node-env development", "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\"", - "build": "tsc", "test": "jest" }, "devDependencies": { diff --git a/update-deploy.sh b/update-deploy.sh new file mode 100644 index 000000000..ea352f08a --- /dev/null +++ b/update-deploy.sh @@ -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." \ No newline at end of file