.NET docker buster images for 6.0 - dockerfile

I need buster image for .NET 6.0
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
What should be for .net6.0 ?

Buster images are images based on Debian 10 (Buster), there is no official images for .NET 6 based on Buster (see full tag listings for SDK and ASP.NET Core), only on Debian 11 (Bullseye), so you can take those (6.0-bullseye-slim).

To Run Your Container can use below commands in debian os
$ docker build .
$ docker images
$ docker run [imageName]

you can use this DockerFile in your Project
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
LABEL Remarks="gET SDK FOM MICROSOFT"
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/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "YieldExample.dll"]

Related

Docker Stuck at building Golang inside AWS EC2

Im going crazy here... im trying to create a docker container with this file:
#Docker
FROM golang:alpine as builder
RUN apk update && apk add --no-cache git make gcc libc-dev
# download, cache and install deps
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
# copy and compiled the app
COPY . .
RUN make ditto
# start a new stage from scratch
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# copy the prebuilt binary from the builder stage
COPY --from=builder /app/_build/ditto .
COPY --from=builder /app/send-email-report.sh /usr/bin/
ENTRYPOINT ["./ditto"]
Running: docker build .
On my Pc it works perfect
BUT in my AWS instance of EC2 same code:
docker build .
Sending build context to Docker daemon 108kB
Step 1/13 : FROM golang:1.18-alpine as builder
---> 155ead2e66ca
Step 2/13 : RUN apk update && apk add --no-cache git make gcc libc-dev
---> Running in 1d3adab601f3
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
v3.16.0-99-g5b6c75ce95 [https://dl-cdn.alpinelinux.org/alpine/v3.16/main]
v3.16.0-108-ge392af4f2e [https://dl-cdn.alpinelinux.org/alpine/v3.16/community]
OK: 17022 distinct packages available
And get Stuck there...
It was working fine in the past, I think nobody has change on that docker file and folder...
Can somebody help me? please

Docker file build error while upgrading to .net core 6 in AWS lambda app

I am working on upgrading the existing containerized lambda application from .NET Core 5 to .NET Core 6. I am getting this error in the Azure pipeline (on run build script):
Step 13/14 : WORKDIR ${LAMBDA_TASK_ROOT} cannot normalize nothing.
The same code is working without any issue when targetting .NET Core 5.
.NET Core 5:
FROM public.ecr.aws/lambda/dotnet:5.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim as build
WORKDIR /workspace
COPY . /workspace
RUN ls
RUN dotnet build -c Release MyAPI.sln -o ./publish
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim as test
WORKDIR /workspace
COPY . /workspace
RUN ls
RUN dotnet test -c Release MyAPI.sln -o ./publish
FROM base as final
WORKDIR ${LAMBDA_TASK_ROOT}
COPY --from=build /workspace/publish
.NET Core 6:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
FROM base as build
WORKDIR /workspace
COPY . /workspace
RUN ls
RUN dotnet build -c Release MyAPI.sln -o ./publish
FROM base as test
WORKDIR /workspace
COPY . /workspace
RUN ls
RUN dotnet test -c Release MyAPI.sln -o ./publish
FROM base as final
WORKDIR ${LAMBDA_TASK_ROOT}
COPY --from=build /workspace/publish

Can't launch Chromium as executable doesn't exists if customized image is build from Dockerfile

FROM alpine:latest
# Copy source to container
RUN mkdir -p /usr/app
# Copy source code
COPY package.json /usr/app
COPY package-lock.json /usr/app
COPY . /usr/app
# Set working directory
WORKDIR /usr/app
# Environment variables
ENV BASE_URL="Local https url"
ENV PARALLEL_RUN=false
ENV TAG=int
ENV PLAYWRIGHT_BROWSERS_PATH=/usr/lib
# npm install
RUN apk add --update npm
RUN apk add chromium
# Run tests
RUN npm run codeceptjs
Above is the Dockerfile. When tried to Build the image from docker file then I am getting below error:
13 8.596 Error: browserType.launch: Failed to launch chromium because executable doesn't exist at /usr/lib/chromium-888113/chrome-linux/chrome
#13 8.596 Try re-installing playwright with "npm install playwright"**
Although, I can see chromium is getting installed at the mentioned path but still it saying "executable not present".
I believe your problem lies with using alpine.
According to the playwright developers, there are no plans to support playwright on alpine. This makes your whole undertaking more complex. It's correct that you need to provide your own chromium and cannot use the browsers that come with playwright. Therefore, you should set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD to prevent any (incompatible) browsers from being loaded.
The chromium executable should be in your Docker image under /usr/bin/chromium-browser. You need to use playwright's browserType.launch to set the path to the executable:
const { chromium } = require("playwright-chromium");
// ...
const browser = await chromium.launch({
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
});
If you want a simpler solution, I would suggest using the Docker image of Zanika, containing chromium and playwright already. Here the link to the tag on DockerHub. At the very least you can see it as a reference implementation if you still want to use your own image.

Docker image creation using nodejs with redis

i am using below Docker file. how can i configure redis in my Dockerfile?
also i am using build command docker build - < Dockerfile but this didn't work out.
if i run this command the following error will show
COPY failed: no source files were specified
FROM node:lts
RUN mkdir -p /app
WORKDIR /app
COPY package*.json /app
RUN yarn
COPY . /app
CMD ["yarn","run","start"]
One cannot use docker build - < Dockerfile to build an image that uses COPY instructions, because those instructions require those files to be present in the build context.
One must use docker build ., where . is the relative path to the build context.
Using docker build - < Dockerfile effectively means that the only thing in the build context is the Dockerfile. The files that one wants to copy into the docker image are not known to docker, because they are not included in the context.

Docker ASPNET Core container with Python installed

I have an application that is running some processes and exposes them through WebAPI. Part of these processes need to execute Python scripts through the IronPython library. For this to happen though, Python 2.7 must also be installed on the system.
Has anyone solved this problem by figuring out how to install Python in the ASPNET Core Docker image (or by any other means). The only other hack I can think of it putting the Python executable into a dependency directory for the API.
Our current Docker File contents:
FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Api.dll"]
You can use the RUN command to install it on the image. Simply add the following to your Dockerfile.
The image I pulled from Dockerhub seemed to be running Debian Linux as the base OS so the following should work. If it's another linux distro as the base in your instance, try yum instead or for windows OS chocolatey.
FROM microsoft/aspnetcore:2.0
RUN apt-get update -y && apt-get install python2.7 -y
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "AIA.Vietnam.dll"]
Now the python executable should be available in /usr/bin/python2.7