.net core 기반 React 프로젝트를 Docker로 빌드 후 배포를 해보려고 합니다.
기본으로 제공되어있는 Dockfile로는 빌드가 진행되지 않고 실패가 떨어지게 될 것 입니다.
RUN apt-get updateRUN apt-get install -y curlRUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glxRUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -RUN apt-get install -y nodejs
React는 node.js 위에서 동작을 하고 npm으로 설치되어있는 여러가지 라이브러리가 필요하기 때문인데요.
ASP.NET Core 및 React.js를 포함한 Visual Studio 컨테이너 도구 | Microsoft Learn를 참고하여 DockerFile를 수정해보겠습니다.
1. 추가해야 될 명령어
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
2. 완성된 DockerFile
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src
COPY ["ProjectSPA1/ProjectSPA1.csproj", "ProjectSPA1/"]
RUN dotnet restore "ProjectSPA1/ProjectSPA1.csproj"
COPY . .
WORKDIR "/src/ProjectSPA1"
RUN dotnet build "ProjectSPA1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ProjectSPA1.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ProjectSPA1.dll"]
'Server > Docker' 카테고리의 다른 글
[Ubuntu] Docker 설치하기 (0) | 2023.10.23 |
---|---|
[Centos] aws linux centos에 docker로 jenkins 띄우기 (0) | 2023.08.08 |
Docker 명령어 (0) | 2023.01.29 |
Docker 설치 - linux편 (0) | 2023.01.29 |
Docker 설치 - windows편 (0) | 2023.01.29 |