Skip to content

Commit

Permalink
Update Dockerfile to use client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-karlsson committed Mar 21, 2024
1 parent 68b4a89 commit 91df163
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
32 changes: 19 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
FROM node:lts-alpine
# Stage 1: Build the React client app
FROM node:lts-alpine as client-builder

# Create app directory
WORKDIR /usr/src/app
WORKDIR /usr/src/client
COPY client/package*.json ./
RUN npm ci --only=production
COPY client/ .
RUN npm run build

# 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 ./
# Stage 2: Build the Node server
FROM node:lts-alpine as server-builder

# RUN npm install
# If you are building your code for production
RUN npm ci --omit=dev
WORKDIR /usr/src/server
COPY server/package*.json ./
RUN npm ci --only=production
COPY server/ .

# Bundle app source
COPY . .
# Copy the built React app from the client-builder stage
COPY --from=client-builder /usr/src/client/build ./public

# Expose the port that the server is running on
EXPOSE 3000
CMD [ "node", "server.js" ]

# Specify the command to run the server
CMD ["node", "server.js"]
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

Some talking fruits

How to update the server:
## How to update the server:

```
docker build . -t nonhumannonsense/council-of-foods:latest
docker push nonhumannonsense/council-of-foods:latest
```

Then update the server, see server repo.

## How to run the server

```
docker build . -t nonhumannonsense/council-of-foods:latest
docker push nonhumannonsense/council-of-foods:latest
```
2 changes: 0 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"dev": "nodemon server.js"
},
"author": "",
Expand Down

0 comments on commit 91df163

Please sign in to comment.