Create docker file for client and server

docker client server example
docker build
docker run
docker tutorial
docker-compose build
dockerfile example

I have a folder structure like this: root/server root/frontend root/

where is somethins like this:


cd server
npm run build;

cd ../client;
npm run build;
mv -R build ../server/client;

cd ../server
npm run start;

so I build the server, then the client, I move the client built file inside my server app and I run the there a way to do something like this with a docker image?

Yes, most of the thing that you can do with a .sh script could be done building a docker image. Howerver, docker images follow often the Single Responisbility Principle, so i would not couple FE and BE in a single image (if they are two different applications) but instead i would do 2 different, then using docker compose, you will be able to manage your multi-container application

let's see a very simple example

Backend: (Dockerfile in server directory)

FROM node:xxx (use your development version)
WORKDIR /server
COPY . /server/
RUN npm run build


CMD npm start

Frontend: (Dockerfile in client directory)

FROM node:xxx (use your development version)
WORKDIR /client
COPY . /client/

RUN npm run build

CMD npm start

docker compose (in the parent directory of server and client

version: 3
    build: ./server
    container_name: server
      - 3000:3000
    build: ./client
    container_name: client

then with docker-compose up --build you can build and run your containers in any moment, see the documentation for other commands (stop, kill, remove ecc)

NOTE: i've written all "by hand", there could be some typo or wrong syntax. Sorry, i will fix!

Create docker file for client and server, Yes, most of the thing that you can do with a .sh script could be done building a docker image. Howerver, docker images follow often the Single  Docker uses a client-server architecture. The Docker client talks to the Docker daemon , which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon.

this is probably similar to the problem your facing:

FROM node:alpine as buildjob_frontend
COPY web/package.json .
COPY web/yarn.lock .
RUN yarn install
COPY web/ .
RUN yarn build

FROM golang:alpine as buildjob_go
RUN mkdir -p /go/src/ && \
  mkdir -p /src/bin/ && \
  apk update && \
  apk add git && \
  apk add make
WORKDIR /go/src/
COPY . .
RUN GOOS=linux make build-server && mv serverbin /src/bin/app

FROM alpine:latest
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* && \
  mkdir -p /src/web/build
COPY --from=buildjob_frontend /build /src/web/build
COPY --from=buildjob_go /src/bin/app /src/
CMD ["./app"]

Builds frontend, builds backend, and copies backend binary and frontend build folder into an alpine image. I can link you the full repo if you need to see how things are linked with eachother

Docker overview, docker run heroiclabs/nakama <command> [options]. Database server use the following connection detail to configure your client to connect to the server:. 3. Create your client. To continue with reminders of Docker’s basics, we will create the client. 3a. Create files. Move to your ‘client’ folder and create the following files: A ‘

In Docker to change directory use the WORKDIR keyword , you need to specify the full path in this section

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

WORKDIR /usr/src/app/client

RUN npm install

RUN npm run build

WORKDIR /usr/src/app


CMD ["node", "server.js"]

A Docker Tutorial for Beginners, A method to create a Java-based client and server to send and receive binary data; The client and server, each run inside a Docker container  In case you use docker-machine to manage a local VirtualBox-based machines the solution is as simple as for boot2docker:. docker-machine upgrade MACHINE_NAME It asks docker-machine to download the latest boot2docker.iso and place it as a new root filesystem in the upgraded VM.

Docker quickstart - Nakama server, server:/app nginx: restart: always build: dockerfile: Dockerfile context: ./controller ports: - '5000:80' client: build: dockerfile: Dockerfile context: . Learn about client access to the database, controlling the container, restoring a dump file, and using Docker to create a MySQL server.

Docker to Docker Networking Between TCP Client and Server, Get the Docker image for Consul; Configure and run a Consul server; Configure and run a Consul client; Interact with the Consul agents; Perform maintenance  docker-machine create Estimated reading time: 10 minutes Create a machine. Requires the --driver flag to indicate which provider (VirtualBox, DigitalOcean, AWS, etc.) the machine should be created on, and an argument to indicate the name of the created machine.

Working with Multiple Containers Using Docker Compose , A quick and practical guide to Docker Client for Java. Now we will create a Dockerfile named Dockerfile.server with the following content: ? To create your first Docker application, I invite you to create a folder on your computer. It must contain the following two files: A ‘ ’ file (python file that will contain the code

  • thanks for the answer, the react app is served by the node app as I want to keep everything on 1 single app without need to deploy 2 different things for an app...your approach is the right one for 2 app while I need only one app...using both your and Marcel answer I fix my problem