I have the following folder structure
src
--ApiGateWays
--BuildingBlocks
--Services
--WebApps
docker-compose.dcproj
docker-compose.yml
docker-compose.override.yml
.dockerignore
Within the Services folder I have an Identity.API project
Services
--Identity
--Identity.API
-- DockerFile
Within the Identity.API project, I have a Docker file defined below
#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:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Services/Identity/Identity.API/Identity.API.csproj", "Services/Identity/Identity.API/"]
COPY ["BuildingBlocks/Common.Logging/Common.Logging.csproj", "BuildingBlocks/Common.Logging/"]
COPY ["BuildingBlocks/EventBus.Messages/EventBus.Messages.csproj", "BuildingBlocks/EventBus.Messages/"]
RUN dotnet restore "Services/Identity/Identity.API/Identity.API.csproj"
COPY . .
WORKDIR "/src/Services/Identity/Identity.API"
RUN dotnet build "Identity.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Identity.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Identity.API.dll"]
There is a "keys" folder and contents within the Identity.API project that I would like to exclude, but I can't seem to get my dockerignore file to exclude it.
Inside my .dockerignore file at the root folder, I have the following entry
**/keys
Every time I launch my Visual Studio Docker Compose debugger, the keys folder and contents are present within the Identity.API container.
What am I doing wrong? Any help appreciated.
Related
Below issue facing while creating docker file in flutter web
enter image description here
anyone have idea about how to create docker file in flutter web.....
I tried many resources but still stuck in issue...
resource or link or solution about same
It is hard to help you without seeing your Dockerfile.
This is the multistaged one I use with nginx:
#Stage 1 - Install dependencies and build the app
FROM debian:latest AS build-env
# Install flutter dependencies
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter path
# RUN /usr/local/flutter/bin/flutter doctor -v
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Run flutter doctor
RUN flutter doctor -v
# Enable flutter web
RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN flutter create .
RUN flutter build web
# Stage 2 - Create the run-time image
FROM nginx:1.21.1-alpine
COPY --from=build-env /app/build/web /usr/share/nginx/html
If you need a highly optimized image I would not use this one. How ever it does the trick for me.
I am following the Reduce your CI cost using Docker to run local tests article and managed to run my tests inside a Ubuntu docker container. However, I have one test which fails after about 10 minutes of running. Here is the error I see:
# flutter test test/lib/mobile/services/sync/sync_service_test.dart
12:25 +0 -1: apiSync It should throw an exception if the sync fails [E]
TimeoutException after 0:10:00.000000: Test timed out after 10 minutes.
dart:isolate _RawReceivePortImpl._handleMessage
However, this test runs fine in macOS (my machine and in Bitrise CI).
To help resolve this issue, I am trying to find a way to debug this test. Is there a way I can remotely debug a test running inside this Docker container?
This is a copy of my modified Dockerfile:
# Need to match the version of Linux your CI is running on
FROM ubuntu:20.04
# Prerequisites
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget libsqlite3-dev
WORKDIR /home/developer
# Download Flutter SDK
ARG flutter_version
RUN git clone https://github.com/flutter/flutter.git -b ${flutter_version}
ENV PATH "$PATH:/home/developer/flutter/bin"
COPY pubspec.* /home/developer/project/
WORKDIR /home/developer/project
RUN flutter pub get
COPY *.yaml *.json /home/developer/project/
COPY android /home/developer/project/android
COPY assets /home/developer/project/assets
COPY doc /home/developer/project/doc
COPY docker /home/developer/project/docker
COPY ios /home/developer/project/ios
COPY lib /home/developer/project/lib
COPY macos /home/developer/project/macos
COPY scripts /home/developer/project/scripts
COPY test /home/developer/project/test
COPY test_environment /home/developer/project/test_environment
COPY tool /home/developer/project/tool
COPY web /home/developer/project/web
# Run basic check to download Dark SDK
RUN flutter doctor
I would like to know the possibility of remote debugging rather than trying to solve the issue for this particular test.
Thanks in advance 🙏 !!!
I am running local testing on macOS using docker-compose and I believe I'm following the getting started documentation exactly. But I get the following error:
% docker-compose up
ERROR: The platform targeted with
the current context is not supported.
Make sure the context in use
targets a Docker Engine.
Any idea why that is happening? Docker Desktop is running.
Versions:
OSX 12.2.1
Docker Desktop 4.5.0
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
Key files:
Dockerfile:
# syntax=docker/dockerfile:1
FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD ["flask", "run"]
docker-compose.yml:
version: "3.9"
services:
web:
build: .
ports:
- "8000:5000"
redis:
image: "redis:alpine"
Use docker compose up instead of docker-compose up.
Also if you are deploying to ECS, the asymmetrical port mapping "8000:5000" will not work. The port mapping has to be symmetrical.
Lastly, if you are deploying to ECS, the build will not work as expected. You can read more about the supported fields here.
https://docs.docker.com/cloud/ecs-compose-features/. So you have to build the image in your local and tag it as <accontId>.dkr.ecr.us-west-2.amazonaws.com/<imageName> and push it to ecs and use the image in your docker-compose file.
I have the following Dockerfile for a very simple spring boot REST application:
# Prepare runtime.
FROM openjdk:8-jre-alpine AS runtime
WORKDIR /app
EXPOSE 80
# Prepare build workspace.
FROM gradle:5.3.0-jdk-alpine AS sdk
WORKDIR /build-workspace
# Setup build workspace.
USER root
RUN chown -R gradle .
USER gradle
# Copy.
COPY build.gradle .
COPY gradle.properties .
COPY src ./src
# Build, Test and publish.
RUN gradle clean bootJar
# App image.
FROM runtime
COPY --from=sdk /build-workspace/build/libs/myApplication-0.0.1-SNAPSHOT.jar ./app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
My docker file is in the root directory of my project, beside build.gradle etc.
when I run:
docker build -t myApplication .
I get the error:
Step 14/15 : COPY --from=sdk
/build-workspace/build/libs/myApplication-0.0.1-SNAPSHOT.jar ./app.jar
COPY failed: stat /var/lib/docker/overlay2/e9441fe0b968bd5776ee860bbca780d6c2037fcf90cb67d01c3b1fd349d3996f/merged/build-workspace/build/libs/myApplication-0.0.1-SNAPSHOT.jar:
no such file or directory
What am I doing wrong in my docker file?
You can add a RUN ls -l /build-workspace/build/libs/ after the RUN gradle clean bootJar to see what’s in that directory.
I'm trying to deploy angular cli project to openshift 3. It continuously failing the build with "Generic Build failure", no farther info on log. Can any one please walk me through the process if I'm wrong, and is there a way to deploy the compiled dist folder and avoid the build process or what is the best practice? Thank You in Advance.
here are my scripts:
package.json
server.js
The approach I use is to create a Jenkins pipeline whose build step does the following
npm install -d
npm install --save classlist.js
$(npm bin)/ng build --prod --build-optimizer
rm -rf node_modules
oc start-build angular-5-example --from-dir=. --follow
You can see that the final step is to kick off a binary build in Openshift passing the contents of the current directory (minus the node_modules which is not needed and rather large). This binary build simply copies the dist folder output of the ng build into a nginx base image plus some configuration files
FROM nginx:1.13.3-alpine
## Copy our nginx config
COPY nginx/ /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## copy over the artifacts in dist folder to default nginx public folder
COPY dist/ /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
A fully working example application which describes how an Angular CLI generated project can be deployed to Openshift 3 can be found at
https://github.com/petenorth/angular-5-example
The application is an Angular 5 app.