From 5c183346888bfa1485e1ec836ffc9fdba2c72262 Mon Sep 17 00:00:00 2001 From: Willow Carretero Chavez Date: Sat, 28 Jan 2023 03:18:51 -0500 Subject: [PATCH] Add ability to run dockerized dev release of app --- .dockerignore | 2 ++ Dockerfile | 25 +++++++++++++++++++++++++ client/src/components/App.js | 2 +- docker-compose.yml | 23 +++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..13dfa36 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.env +node_modules/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e15fd01 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM node:16 + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm ci --only=production + + +# Bundle app source +COPY . . + +ARG BUILD_MODE=development +# build with webpack +RUN npx webpack build --config ./webpack.config.js --mode $BUILD_MODE + + +EXPOSE 3000 +CMD [ "node", "server/server.js" ] \ No newline at end of file diff --git a/client/src/components/App.js b/client/src/components/App.js index 1c7fbb8..b5b2035 100644 --- a/client/src/components/App.js +++ b/client/src/components/App.js @@ -95,7 +95,7 @@ class App extends Component { handleLogin = () => { let oldLink = window.location.pathname + window.location.search; let link = window.location.origin.replace("http:", "https:") + "/api/signUpLogin"; - if (link.includes("localhost:5000")) link = window.location.origin + "/api/signUpLogin"; + if (link.includes("localhost:5000") || link.includes("localhost:3000")) link = window.location.origin + "/api/signUpLogin"; // TODO: There has to be a better way to detect if we're running a dev build let encodedLink = encodeURIComponent(link); this.props.cookies.set("redirectLink", oldLink, { path: "/" }); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c209c5e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.9" + +services: + web-dev: + build: + context: . + args: + - BUILD_MODE=development + ports: + - "3000:3000" + depends_on: + - mongo-dev + environment: + - FIREROAD_LINK=https://fireroad-dev.mit.edu/ + - DATABASE_NAME=dev + - ATLAS_SRV=mongodb://root:example@mongo-dev:27017 + - ENV=development + mongo-dev: + image: mongo + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example \ No newline at end of file