Does anyone has experice with circleci-pipeline?

Amit Choudhary:
does anyone has experice with circleci-pipeline ?

Deepak Kumar:
the image that you are pushing is in public repository or private ?

Amit Choudhary:
private

Deepak Kumar:
then in ssh stage add the docker login command

Amit Choudhary:
it’s able to ssh and push the image

Amit Choudhary:
it’s not able to deploy the image on target server

Amit Choudhary:
getting error at deploy stage

Amit Choudhary:
if you want i can share the dockerfile as well

Deepak Kumar:
yes when you ssh to target server you need to do the docker login in the target server so that it can pull the docker image.

Amit Choudhary:
yes that’s there

Amit Choudhary:
like even i am doing manual pull of docker image then also getting error

Amit Choudhary:

# Use an official Node.js runtime as the base image
FROM node:16

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy the rest of the project files to the working directory
COPY . .

# Build the React app
RUN npm run build

# Expose a port (usually 3000) that the app will listen on
EXPOSE 3006

# Define the command to run the app
CMD ["npm", "start"]

Amit Choudhary:
Dockerfile

Amit Choudhary:
can you check if there’s some misconfiguration in image or something in Dockerfile or Pipeline script ?

Deepak Kumar:
in the pipeline script you are not logging in to the docker hub when you do the ssh to the target server

Amit Choudhary:
how to do it ?

Deepak Kumar:
add this line and try
ssh -o “StrictHostKeyChecking no” [email protected] “echo “$DOCKERHUB_PASS” | docker login -u “$DOCKERHUB_USER” --password-stdin;docker pull $DOCKERHUB_USER/my-nextjs-app:latest && docker run -d -p 5006:3006 $DOCKERHUB_USER/my-nextjs-app:latest”

Amit Choudhary:
ok

Amit Choudhary:
and more issue i face is after one build it’s not able to push the image to DockerHub ?

Deepak Kumar:
have you configured the environment variables $DOCKERHUB_PASS and $DOCKER_USER in the circleci.