Skip to content

Commit

Permalink
Add scripts to deploy using Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Sothatsit committed May 12, 2024
1 parent 98fc2cd commit 897f06c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
node_modules/
.next/
.git/
.env.local
.github/
.idea/
/build

26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:20-slim AS base

FROM base AS base-deps
WORKDIR /app
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
curl \
python3 \
libkrb5-3 \
libkrb5-dev \
build-essential \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

FROM base-deps as build-deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
RUN npm install -g firebase-tools
RUN mkdir -p node_modules/.cache && chmod -R 777 node_modules/.cache

FROM base-deps as builder
WORKDIR /app
COPY --from=build-deps /app/node_modules ./node_modules
COPY . .
9 changes: 8 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ usage() {
# =========================
do_install_gcloud=false
do_skip_cors=false
in_docker=false

for var in "$@"
do
if [[ "$var" == "--create-gcloud-installation" ]]; then
do_install_gcloud=true
elif [[ "$var" == "--skip-cors" ]]; then
do_skip_cors=true
elif [[ "$var" == "--docker" ]]; then
in_docker=true
else
usage
exit 1
Expand Down Expand Up @@ -89,7 +92,11 @@ echo " "
echo "========================================================="
echo "Connecting to Firebase, you may be prompted to sign in..."
echo "========================================================="
npx firebase login || { echo "Signing you into Firebase failed!" ; exit 1; }
if [ "$in_docker" = true ]; then
npx firebase login --no-localhost || { echo "Signing you into Firebase failed!" ; exit 1; }
else
npx firebase login || { echo "Signing you into Firebase failed!" ; exit 1; }
fi

echo " "
echo "================================================================="
Expand Down
2 changes: 2 additions & 0 deletions deploy_docker.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t misinfogame .
docker run -it misinfogame ./deploy.sh --docker
4 changes: 4 additions & 0 deletions deploy_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker build -t misinfogame .
docker run -it misinfogame ./deploy.sh --docker

0 comments on commit 897f06c

Please sign in to comment.