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.
Related
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.
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 just installed Gradle, manually by downloading the zip and then unzipping it, and verified it installed fine with gradle -v .
I have it located at Users/username/gradle/ . I set it on the home path for linux by running this line:
export PATH=$PATH:gradle/gradle-5.2.1/bin/
However, when I try to init my first Scala project, I run this command:
gradle init --type scala-library
However, it complains that:
-bash: gradle/gradle-5.2.1/bin/gradle: No such file or directory
So fine, I check my directory structure, and that file is definitely in there. What gives?
You should check whether gradle file exists and is an executable ls -l gradle/gradle-5.2.1/bin/gradle. Also if Users/gradle/ means user's home directory shouldn't your path be something like $PATH:$HOME/gradle/gradle-5.2.1/bin/ ?
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.
I have built a project using cmake (LLVM project) and tried to install it by issuing the following command:
$ cmake3 --build . --target install
If I run it using root then there is no problem and the files will be installed under the directory /usr/local/.
My problem is when I want to install the project using normal user.
I get the following error:
CMake Error at cmake_install.cmake:36 (file):
file INSTALL cannot set permissions on "/usr/local/include/llvm"
I have changed the permission of directory /usr/local/ to 777 recursively, and their ownership to root:wheel and I added my normal user to group wheel. But I still cannot install the files into the /usr/local/ directory.
The main issue is about building project in Eclipse which fails at "Build Install" command.
chmod 777 -R / is a very scary command. I've destroyed a system once by doing that.
The philosophy I use for this is:
If I need to deploy something through my IDE to debug or test before packaging, I deploy it locally within my home directory.
I only install stuff to my system (outside of home) if it has been packaged first (*.deb, *.rpm, *.tar.gz) so that I can remove it without problems.
For me, I do this with:
cmake $src
cmake --build . --target install -- DESTDIR=stage
This will configure my project, make it, then install it locally in a folder called ./stage which resides in my build directory. I can then run my executable from ./stage/usr/bin. Note that this only works if make is your generator.
Once I've tested it and I'm happy, I package it and deploy to my system or upload to a repository:
cpack
sudo dpkg -i <package>.deb
We should use USE_SOURCE_PERMISSIONS in our install function.
Example:
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Release/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" USE_SOURCE_PERMISSIONS)