![]() So I deleted the node_modules folder and reinstalled the packages: rm -rf node_modules This can cause problems when using native modules. To my surprise, the build also failed in my dev container, with a rather useless error message:Įrror: PostCSS received undefined instead of CSS stringįortunately, my instincts were right: something was wrong with my node_modules folder, because I had installed the packages on Windows but wanted to use them on Linux. gitattributes file to the repository: * text=auto eol=lf ![]() ![]() The best way to fix this problem is to use the same line endings in both operating systems. Since I cloned the repository on Windows, all line endings were considered changed on Linux. This was because Git uses different line endings by default in different operating systems. Visual Studio Code also warned me that it was treating the repository folder as unsafe because it was mounted from the host and was not in my home directory:īy clicking the Manage Unsafe Repositories button, I was able to mark the folder as safe and get rid of the warning:Īs soon as Git was initialized in Visual Studio Code, it recognized all files as modified: And when I opened a terminal, it ran a bash shell inside the container: Visual Studio Code status bar indicated that it was connected to my container. I quickly traced the problem to the NPM script setting an environment variable with a syntax that does not work on Windows: The project would not build with the following error message:īUILD_TARGET is not recognized as an internal or external So I decided to try Visual Studio Code Dev Containers. When I take the IP address and put it in my web browser, it’s possible to see the website is running on the new container.I wanted to fix a bug in Tabliss that had been bothering me for some time, but I could not build the project on Windows without changing the NPM scripts. Now that it’s running, I want to attach a shell so that I can get this container’s IP address. Let’s go ahead and right-click that and run this container. Once that’s done, I’m going to click on the Docker icon in the activity bar on the left-hand side.Īnd we can see the new container image listed under Images. You’ll see the Docker build command running in the terminal below. I’m going to use the default tag and hit Enter. Simply right-click on the Dockerfile, then click on Build Image. Now that I’m finished, I can actually build my container image right from VS Code instead of using the command line. I’m going to specify the COPY wwwroot c:/inetpub/wwwrootįinally, I’m going to expose port 80 and then save this Dockerfile. ![]() Now let’s copy some files to the new container image by using the copy snippet. ![]() Below, I’ll specify the latest Microsoft IIS image, which I have already downloaded - FROM microsoft/iis:latest Inside my Dockerfile, I’ll hit Control-Space to bring up a list of snippets that are available with the Docker extension.įirst I need to specify the image that I’m going to be building from. In this post, we’ll create a Dockerfile that we can use to build a new container image.įirst, I’ll create a new file in my workspace called Dockerfile. The Docker extension for Visual Studio Code by Microsoft has a lot of handy features when it comes to generating the files necessary for building and deploying Docker containers. ![]()
0 Comments
Leave a Reply. |