Nuxt dev + docker-compose + nginx proxy manager error - docker-compose

i am creating my first nuxtjs app with nginx proxy manager and docker-compose.
....
app:
container_name: app
command: npm run dev
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- '45230:45230'
volumes:
- ./frontend:/app
- ./frontend/node_modules:/app/node_modules/
FROM node:16-alpine3.11
WORKDIR /app
COPY package.json ./app
COPY . /app
RUN npm install
EXPOSE 45230
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=45230
This is my Docker-compose.yml + Dockerfile to run the app in development mode.
If i start my app everything works as excepted but every 30-60sec i got this error in chrome dev tool
GET https://dev.domain.de/_loading/sse net::ERR_HTTP2_PROTOCOL_ERROR 200
Do you know how i can fix this error? does this error appears because i run nuxt with npm run dev?

Related

Can't connect to host machine to any port from docker container linux

i can't connect to my localhost mongodb from docker container.
I can get page nginx if run curl 172.17.0.1 or (host.docker.internal) inside docker container, but if i try use another port curl not outputs nothing. Any help?
On windows machine all works fine, but i noticed that there is another port for connect to host machine host.docker.internal = 192.168.65.2
I think maybe linux blocks ports for docker container?
System: Ubuntu 18.04.6 LTS
Docker: 20.10.22, build 3a2c30b
Docker file
# build step
# Base image
FROM node:18
# Create app directory
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install app dependencies
RUN npm install
# Bundle app source
COPY . .
# Creates a "dist" folder with the production build
RUN npm run build
# Start the server using the production build
CMD [ "node", "dist/main.js" ]
docker-compose file
version: '3.8'
services:
api:
build: .
container_name: api-container
volumes:
- .:/app
- /app/node_modules
ports:
- 127.0.0.1:${APP_PORT}:${APP_PORT}
env_file:
- .env

Error Connect a docker Instance to mongoDB atlas

I made a go App conected to MongoDB Atlas and works fine when run locally, but when i tried to create docker-compose i get this error
error parsing uri: lookup _mongodb._tcp.cluster0.mrknb.mongodb.net on 127.0.0.11:53: read udp 127.0.0.1:37379->127.0.0.11:53: i/o timeout
My connection string is :
mongodb+srv://apiVentas:<password>#cluster0.mrknb.mongodb.net/<dbname>?retryWrites=true&w=majority
My DockerFile is:
FROM golang:alpine AS builder
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go test ./...
RUN go build -o main .
WORKDIR /dist
RUN cp /build/main .
FROM scratch
COPY --from=builder /dist/main /
ENTRYPOINT ["/main"]
And Docker-compose is
version: "3"
services:
web:
container_name: apiVentas
restart: always
build: .
ports:
- "3000:3000"
volumes:
- .:/home/perajim/go/src/api.ventas
dns:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
I add my IP to list in mongoDB Atlas
It's necessary some configuration in docker?
MongoDB Atlas runs on port 27017 , change the port binding and then try.

KeystoneJS docker-compose can't connect mongo db

I am trying to deploy keystoneJS app on the server. Before that I want to test it locally.
I started mongoDB locally. Then use the Dockerfile from the documentation https://www.keystonejs.com/guides/deployment here, I can't run it. I get the error below:
✖ Connecting to database
Error: Server selection timed out after 30000 ms
at /home/node/node_modules/#keystonejs/utils/dist/utils.cjs.prod.js:54:26
at async executeDefaultServer (/home/node/node_modules/#keystonejs/keystone/bin/utils.js:109:3) {
errors: {
MongooseAdapter: MongoTimeoutError: Server selection timed out after 30000 ms
at Timeout._onTimeout (/home/node/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
name: 'MongoTimeoutError',
reason: [MongoNetworkError],
[Symbol(mongoErrorContextSymbol)]: {}
}
}
}
error Command failed with exit code 1.
I googled seems didn't know about local mongodb://localhost:27017.
Then I decided to use docker-compose:
Here is the docker-compose.yml
version: '3'
services:
app:
container_name: my-admin
restart: always
build: .
volumes:
- .:/mycode
environment:
- MONGO_URI=mongodb://mongo:27017
ports:
- "80:3030"
links:
- mongo
mongo:
image: mongo:latest
restart: always
ports:
- "27017:27017"
when I run docker-compose up, got the same error.
Also tried this:
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new Adapter({mongoUri: "mongodb://mongo:27017/myapp"}),
onConnect: initialiseData,
});
Any help? Thanks!
EDIT
Here is the Dockerfile
# https://docs.docker.com/samples/library/node/
ARG NODE_VERSION=12.10.0
# https://github.com/Yelp/dumb-init/releases
ARG DUMB_INIT_VERSION=1.2.2
# Build container
FROM node:${NODE_VERSION}-alpine AS build
ARG DUMB_INIT_VERSION
WORKDIR /home/node
RUN apk add --no-cache build-base python2 yarn && \
wget -O dumb-init -q https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 && \
chmod +x dumb-init
ADD . /home/node
RUN yarn install && yarn build && yarn cache clean
# Runtime container
FROM node:${NODE_VERSION}-alpine
WORKDIR /home/node
COPY --from=build /home/node /home/node
EXPOSE 3000
CMD ["./dumb-init", "yarn", "start"]

How to dockerize my dotnet core + postgresql app?

I have a dotnet core application created with Angular template that communicates with a postgresql database.
On my local machine, I run the following command on my terminal to run the database container:
docker run -p 5432:5432 --name accman-postgresql -e POSTGRES_PASSWORD=mypass -d -v 'accman-postgresql-volume:/var/lib/postgresql/data' postgres:10.4
And then by pressing F5 in VsCode, I see that my application works great.
To dockerise my application, I added this file to the root of my application.
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
# install nodejs for angular, webpack middleware
RUN apt-get update
RUN apt-get -f install
RUN apt-get install -y wget
RUN wget -qO- https://deb.nodesource.com/setup_11.x | bash -
RUN apt-get install -y build-essential nodejs
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Web.dll"]
Now I think I have to create a docker-compose file. Would you please help me on creating my docker-compose.yml file?
Thanks,
I figured it out, here is my final version of docker-compose.yml file:
version: '3'
services:
web:
container_name: 'accman-web-app'
image: 'accman-web'
build:
context: .
dockerfile: Dockerfile
ports:
- '8090:80'
depends_on:
- 'postgres'
networks:
- accman-network
postgres:
ports:
- '5432:5432'
container_name: accman-postgresql
environment:
- POSTGRES_PASSWORD=mypass
volumes:
- 'accman-postgresql-volume:/var/lib/postgresql/data'
image: 'postgres:10.4'
networks:
- accman-network
volumes:
accman-postgresql-volume:
networks:
accman-network:
driver: bridge
You can use composerize to find out how you can add services to your docker-compose file.
Now you can run these following commands consecutively:
docker-compose build
docker-compose up
And voila!

Trying to connect a NodeJS app to MongoDB via Docker Compose

I'm following a MongoDB + NodeJS tutorial with my app. Everything works without Docker.. and I can in fact get the app to work up until it needs to connect to MongoDB.
If my app doesn't see MongoDB, it will print out an error and halt.
Here's my files
.env
NODE_VIEWS_PATH=../
NODE_PUBLIC_PATH=../
MONGODB_URI='mongodb://127.0.0.1:27017/myappsdb'
...
Dockerfile
FROM node:carbon
# Create app directory
WORKDIR /usr/src/mahrio
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm install --only=production
COPY . .
EXPOSE 6085
CMD ["npm", "start"]
docker-compose.yml
version: "2"
services:
app:
container_name: someappname
restart: always
build: .
ports:
- "6085:6085"
links:
- mongo
depends_on:
- mongo
mongo:
container_name: mongo
image: mongo
volumes:
- ./tmp:/data/db
ports:
- "27017:27017"
When using docker-compose, for a container to connect to another container it can use the service name as a hostname to connect.
In your case, the node app needs to connect to mongo:27017 rather than localhost:27017, since localhost from the respective of the app container will refer to itself and not to your machine.
Therefore, change the mongo url to MONGODB_URI='mongodb://mongo:27017/myappsdb'. Also make sure that you consume the env file by adding:
app:
...
env_file:
- file.env