Skip to content

Commit

Permalink
updated dockerFile for upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Radoslav Radev committed Apr 4, 2024
1 parent 29f9285 commit 3815357
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 47 deletions.
3 changes: 3 additions & 0 deletions Backend/APIGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
app.UseAuthorization();


if (app.Environment.IsDevelopment())
{
app.UseSwaggerForOcelotUI(opt => { opt.PathToSwaggerGenerator = "/swagger/docs"; });
}


app.UseOcelot();
Expand Down
36 changes: 36 additions & 0 deletions Backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:latest AS base

# Install NFS client utilities
RUN apt-get update && \
apt-get install -y nfs-common && \
apt-get clean

USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Upload/Upload.csproj", "Upload/"]
RUN dotnet restore "Upload/Upload.csproj"
COPY . .
WORKDIR "/src/Upload"
RUN dotnet build "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
ENV CONSUL_IP=consul-service

WORKDIR /app
COPY --from=publish /app/publish .
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
USER $APP_UID
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
36 changes: 36 additions & 0 deletions Backend/Dockerfile_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:latest AS base

# Install NFS client utilities
RUN apt-get update && \
apt-get install -y nfs-common && \
apt-get clean

USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Upload/Upload.csproj", "Upload/"]
RUN dotnet restore "Upload/Upload.csproj"
COPY . .
WORKDIR "/src/Upload"
RUN dotnet build "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
ENV CONSUL_IP=consul-service

WORKDIR /app
COPY --from=publish /app/publish .
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
USER $APP_UID
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
36 changes: 36 additions & 0 deletions Backend/Dockerfile_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:latest AS base

# Install NFS client utilities
RUN apt-get update && \
apt-get install -y nfs-common && \
apt-get clean

USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Upload/Upload.csproj", "Upload/"]
RUN dotnet restore "Upload/Upload.csproj"
COPY . .
WORKDIR "/src/Upload"
RUN dotnet build "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
ENV CONSUL_IP=consul-service

WORKDIR /app
COPY --from=publish /app/publish .
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
USER $APP_UID
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
36 changes: 36 additions & 0 deletions Backend/Dockerfile_3
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:latest AS base

# Install NFS client utilities
RUN apt-get update && \
apt-get install -y nfs-common && \
apt-get clean

USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Upload/Upload.csproj", "Upload/"]
RUN dotnet restore "Upload/Upload.csproj"
COPY . .
WORKDIR "/src/Upload"
RUN dotnet build "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
ENV CONSUL_IP=consul-service

WORKDIR /app
COPY --from=publish /app/publish .
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
USER $APP_UID
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
59 changes: 33 additions & 26 deletions Backend/Render/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# Install FFmpeg
# Use Ubuntu as the base for the custom .NET environment
FROM ubuntu:20.04 AS base

# Install .NET dependencies, NFS support, and other essential tools
RUN apt-get update && apt-get install -y \
software-properties-common \
nfs-common \
&& rm -rf /var/lib/apt/lists/*

# Install Microsoft package signing key and repository
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb

# Install .NET SDK and Runtime
RUN apt-get update && \
apt-get install -y ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-8.0 dotnet-runtime-8.0

ENV APP_UID=1000

USER $APP_UID

WORKDIR /app

EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Render/Render.csproj", "Render/"]
RUN dotnet restore "Render/Render.csproj"
COPY . .
WORKDIR "/src/Render"
RUN dotnet build "Render.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN mkdir -p /app/data

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Render.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Copy the rest of your application's code and follow the same build steps as before
COPY . /app

FROM base AS final
ENV CONSUL_IP=consul-service
# Assuming you have a similar structure for the build and publish stages,
# you can follow the same approach as in your original Dockerfile.
# Remember to adjust paths and commands as needed for your application.

WORKDIR /app
COPY --from=publish /app/publish .
COPY Render/entrypoint.sh /entrypoint.sh
# Final setup
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
RUN chmod +x /entrypoint.sh && chown $APP_UID /app/data
USER $APP_UID


ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
54 changes: 33 additions & 21 deletions Backend/Upload/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# Use Ubuntu as the base for the custom .NET environment
FROM ubuntu:20.04 AS base

# Install .NET dependencies, NFS support, and other essential tools
RUN apt-get update && apt-get install -y \
software-properties-common \
nfs-common \
&& rm -rf /var/lib/apt/lists/*

# Install Microsoft package signing key and repository
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb

# Install .NET SDK and Runtime
RUN apt-get update && \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-8.0 dotnet-runtime-8.0

ENV APP_UID=1000

USER $APP_UID

WORKDIR /app

EXPOSE 8080
EXPOSE 8081
RUN mkdir -p /app/data

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Upload/Upload.csproj", "Upload/"]
RUN dotnet restore "Upload/Upload.csproj"
COPY . .
WORKDIR "/src/Upload"
RUN dotnet build "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN mkdir -p /app/data

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Upload.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Copy the rest of your application's code and follow the same build steps as before
COPY . /app

FROM base AS final
ENV CONSUL_IP=consul-service
# Assuming you have a similar structure for the build and publish stages,
# you can follow the same approach as in your original Dockerfile.
# Remember to adjust paths and commands as needed for your application.

WORKDIR /app
COPY --from=publish /app/publish .
# Final setup
COPY Upload/entrypoint.sh /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh
USER root
RUN chmod +x /entrypoint.sh && chown $APP_UID /app/data
USER $APP_UID
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]


0 comments on commit 3815357

Please sign in to comment.