Browse Source

Added Docker files

master
galmio 9 months ago
parent
commit
91b48518bb
  1. 25
      Dockerfile
  2. 8
      client/Dockerfile
  3. 17
      docker-compose.prod.yml
  4. 28
      docker-compose.yml
  5. 2
      server/.dockerignore
  6. 11
      server/Dockerfile

25
Dockerfile

@ -0,0 +1,25 @@
# Set up and build the client
FROM node:lts-slim as client
WORKDIR /usr/app/client/
COPY client/package*.json ./
RUN npm install -qy
COPY client/ ./
RUN npm run build
# Copy build dir to maintain the current production version local
FROM node:lts-slim
WORKDIR /usr/app
COPY --from=client /usr/app/client/dist/ ./client/dist/
# Set up the server
WORKDIR /usr/app/server/
COPY server/package*.json ./
RUN npm install -qy
COPY server/ ./
ENV PORT 8000
EXPOSE 8000
CMD ["npm", "start"]

8
client/Dockerfile

@ -0,0 +1,8 @@
FROM node:lts-slim
RUN mkdir -p /usr/app
WORKDIR /usr/app
COPY package*.json ./
RUN npm ci -qy
COPY . .
EXPOSE 2500
CMD [ "npm", "start" ]

17
docker-compose.prod.yml

@ -0,0 +1,17 @@
version: "3"
services:
fcso:
build: .
container_name: "fcso"
hostname: "fcso"
ports:
- "8000:8000"
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 8000
networks:
default:
external:
name: caddy_net

28
docker-compose.yml

@ -0,0 +1,28 @@
version: "3"
services:
client:
build:
context: ./client/
command: npm start
image: fcso_client
ports:
- "2500:2500"
env_file: ./server/.env
volumes:
- ./client:/usr/app
- /usr/app/node_modules
depends_on:
- server
server:
build:
context: ./server/
command: /usr/app/node_modules/.bin/nodemon app/server.js
image: fcso_server
ports:
- "4000:4000"
volumes:
- ./server:/usr/app
- /usr/app/node_modules
environment:
- NODE_ENV=development

2
server/.dockerignore

@ -0,0 +1,2 @@
node_modules
npm-debug.log*

11
server/Dockerfile

@ -0,0 +1,11 @@
FROM node:lts-slim
RUN mkdir -p /usr/app
WORKDIR /usr/app
COPY package*.json ./
RUN npm ci -qy
COPY . .
EXPOSE 4000
CMD ["npm", "start"]
Loading…
Cancel
Save