I am creating my first Nuxtjs app but I want to use Docker-compose. I was able to Dockerize my application following this tutorial: https://dockerize.io/guides/docker-nuxtjs-guide
Now I want to bring it to the next level using compose but I'm not too familiar with Serverside-rendering and how this could affect my docker-compose file. Unfortunately I cannot find any guide on how to use docker-compose on NuxtJS apps. Do you know where I can find a good guide for it? Thanks.
UPDATE:
I created a docker-compose.yml file and is working but still I can't find any guide to see if it is a good yml file (best practices etc.)
version: '3'
services:
web:
build: .
command: npm run dev
ports:
- '3000:3000'
If you can already run your app in Docker, you won't gain much from Docker Compose, unless you need to run multiple containers. As stated in Overview of Docker Compose, Compose is a tool for defining and running multi-container Docker applications.
Based on the linked tutorial, docker-compose.yaml could look something like this:
version: "3"
services:
nuxt:
image: nuxtjs-tutorial:latest
ports:
- "3000:3000"
environment:
- NUXT_HOST="0.0.0.0"
- NUXT_PORT="3000"
The environment variables do not need to be set from the Compose file, this is just an example. Compose allows you to set many options, as described in the Compose file reference. For example, you could run the app in Compose using entrypoint instead of CMD in Dockerfile. Or you could only copy package.json in Dockerfile, build the dependencies during image build, and mount your code using volumes.
I found multiple example references online, but I wouln't consider any of them best practice. Best to read the official Documentation.
Regarding your update, based on the Dockerfile in the tutorial, you do not even need the build and command entries, only image and ports. But as I said above, you can set many options from Compose, best described in official documentation.
Related
I'm new to deploying an app, as this is the first time I've done it. I'm trying to deploy my mern app to an aws ec2 instance with the intention to use mongodb atlas, I'm using a ubuntu 20.04 server.
I'm following this guide https://keithweaverca.medium.com/setting-up-mern-stack-on-aws-ec2-6dc599be4737 and I've got to part after I've pulled my github repo to the ubuntu server, everything is working up to yet, I skipped the mongodb section of the guide, as I have already created a mongodb cluster.
I'm not sure what to do now, my repo folder is split like this...
- frontend
- build
- public
- src
- Components
- images
... other files in src
- package.json
- backend
- server.js
- models
- routes
- package.json
... a few other irrelevant files (node_modules, etc.)
Although the guide doesn't say to, don't I need to run 'npm run build' in the frontend directory? after I've ran 'npm install'?
If so, my code isn't compiling and I'm not sure why, it says there is a memory leak, and javascript overload.
I know this is a lot of questions, without much detail, but I don't even understand this well enough to give more info. Any questions please ask. I just need to know what commands to run after I've pulled my code from the github repo.
I'm trying to add an Azure Function project to a docker-compose file created in Visual Studio 2019 (16.7.6), but this causes the solution to fail to build.
(Docker for Windows 2.4.0.0 (48506), with WSL2 support enabled, running in Linux container mode on Windows 10 Pro 2004)
Steps to reproduce:
Create a new solution with a Web Api project 'Web' that includes docker
support.
Add a new Azure Function project 'Func' with an Http trigger
function and then added docker support via Visual Studio Add >
Docker Support option.
Add 'Container Orchestration Support' to Web
project to generate a docker-compose.yml file that has the web app
At this point the solution builds debugging works for the web or func app in docker or docker-compose - all good.
When 'Func' project is added manually to docker-compose.yml the solution no longer builds:
CTC1031 Linux containers are not supported for Func project
Project: docker-compose
File: Microsoft.VisualStudio.Docker.Compose.targets
Line 303
However, I can run docker-compose fine from the command line:
docker-compose -f docker-compose.yml up
and both Web and Func app start up fine.
My docker-compose.yml file is
version: '3.4'
services:
web:
image: ${DOCKER_REGISTRY-}web
build:
context: .
dockerfile: Web/Dockerfile
func:
image: ${DOCKER_REGISTRY-}func
build:
context: .
dockerfile: Func/Dockerfile
Any ideas why I get the above error when building the solution in Visual Studio?
Have the same issue. It seems that docker-compose project type allows to set up dependencies only to specific type of projects, like Sdk="Microsoft.NET.Sdk.Web", and does not allow to library projects like Sdk="Microsoft.NET.Sdk". Referencing Dockerfile from docker-compose.yml automatically sets up reference.
In case of wrong project type compose works, but compilation of docker-compose project fails.
I got the error as well:
CTC1031 Linux containers are not supported for
It probably means that your Output type for the project is set to Class Library instead of Console Application.
I'm using VS Code Dev Container extension to develop and run my app inside a Docker container.
I'm using a docker-compose.yaml to re-use an already defined image with a dependent service.
Inside that docker-compose.yaml file I have yet another service for testing purposes. When VS Code starts it builds all of the services inside my docker-compose.yaml file, not just the two I need to develop my application.
I can see Dev Container extension runs the command Start: Run: docker-compose --project-name proj1 -f c:\dev\proj1\docker-compose.yaml -f c:\dev\proj1\.devcontainer\docker-compose.yml up -d --build
If it would have passed the service defined in devcontainer.json it would have built only it.
Is there a way to instruct VS Code's Dev Container extension to build only the service I need for my development?
manifest.yml file:
---
applications:
- name: myapp1
memory: 512M
command: python abc.py
no-route: true
Procfile:
web: python abc.py
When i delete the Procfile my script does not run, even though i have specified a command to start the script in manifest file. Also, the fact the Procfile has web: in it makes me think it's trying to run it as a webapp? it is not meant to run as a webapp with an open port, it is only meant to make outbound connections.
The procfile may be needed, depending on the Cloud Foundry version (only an old version). See this Python buildpack information.
You can use the command section in the manifest file to specify the start command (as shown in your example).
If your app is not a web app and does not have a route, you need to specify the no-route option in the manifest file. Else the health checker will fail because it tries to access your app as "web app" and test its accessibility.
I'm asking if it's possible to have a docker volume plugin inspect a starting image's label metadata in order to take some additional action? I'd like to see said action include mounting a device, but I'm not sure if such is yet possible with a driver plugin, nor have I seen any mention of say device plugin lately.
I'm trying to see if there are ways to enable the nvidia-docker-plugin in the scope of docker-compose files like so:
test:
image: ubuntu
volume_driver: nvidia-docker-driver
labels:
nvidia.gpu: "0,1"
command: nvidia-smi
Relevant issue with context: https://github.com/NVIDIA/nvidia-docker/issues/39
Just resurrecting this old issue to say that this is now solved by nvidia-docker-compose.