How should I set up cipher suites for Java TLS - kubernetes

i build myself docker image use jre1.8.0_341 + alpine + glibc(2.33)
first:
I downloaded the jar package of jre1.8.0_341
Below is my Dockerfile:
FROM alpine:latest
ADD jre1.8.0_341/jre8.tar.gz /usr/java/jdk/
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.33-r0/glibc-2.33-r0.apk
RUN apk add glibc-2.33-r0.apk
WORKDIR /
Next build the docker image
docker build -f Dockerfile -t myself:latest .
when i run this imgaes
docker run -it myself:latest /bin/bash
Get java version
but i use "FeignClient" to Request other services
report an error: “javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure”
so i add Java startup parameters -Djavax.net.debug=all
and Compare TLS packets using "openjdk:8-jre-alpine" as the base image
I found that there is no "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" in the "cipher suites" parameter during the "Produced ClientHello handshake message" phase
How should I set up cipher suites for Java TLS?

Related

running elixir on buildkite with docker-compose fails with dependencies

i have the following dockerfile for an elixir+phoenix app
FROM elixir:latest as build_base
RUN apt-get -y update
RUN apt-get -y install inotify-tools curl
ARG TARGETARCH
RUN if [ ${TARGETARCH} = arm64 ]; then \
curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-${TARGETARCH}.tar.gz \
;else \
curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-x64.tar.gz \
;fi
RUN tar -xvf /tmp/dart-sass.tar.gz -C /tmp
RUN mv /tmp/dart-sass/sass /usr/local/bin/sass
RUN mkdir -p /app
WORKDIR /app
COPY mix.* ./
RUN mix local.hex --force
RUN mix archive.install hex phx_new --force
RUN mix local.rebar --force
RUN mix deps.clean --all
RUN mix deps.get
RUN mix --version
RUN mix deps.compile
COPY assets assets
COPY vendor vendor
COPY lib lib
COPY config config
COPY priv priv
COPY test test
RUN mix compile
the docker-compose file looks like the following
services:
web:
build:
context: .
dockerfile: Dockerfile
target: build_base
volumes:
- ./:/app
ports:
- "80:80"
command: mix phx.server
I'm trying to run docker-compose as part of the build step in buildkite, this is an extract of the step in buildkite
- label: "run web"
key: "web"
commands:
- mix phx.server
plugins:
- docker-compose#v4.9.0:
run: web
config: docker-compose.yml
however when running web i see everything happens properly including the package installation, however when running the application i see the following error
web_1 | Unchecked dependencies for environment dev:
web_1 | * telemetry_metrics (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
and the list goes on and on, this works fine on my local machine, its only when running on buildkite. does anyone have any idea on how to fix this ?

Dockerize flutter web project

I'm trying to dockerize my flutter web project. And an image was created and the site run perfectly just the pictures of my website are not found and not displayed and I don't know why.it gave me this error :
172.17.0.1 - - [12/May/2022 14:25:04] "GET / HTTP/1.1" 200 -
172.17.0.1 - - [12/May/2022 14:25:04] code 404, message File not found
172.17.0.1 - - [12/May/2022 14:25:04] "GET /packages/image_cropper_for_web/src/croppie/js/croppie.css HTTP/1.1" 404 -
172.17.0.1 - - [12/May/2022 14:25:05] code 404, message File not found
172.17.0.1 - - [12/May/2022 14:25:09] "GET /assets/photos/bgfinal.png HTTP/1.1" 404 -
172.17.0.1 - - [12/May/2022 14:25:09] code 404, message File not found
Dockerfile:
FROM ubuntu:20.04
RUN apt-get update
ARG DEBIAN_FRONTEND=noninteractive
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
# download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Run flutter doctor
RUN flutter doctor
# 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 build web
# Record the exposed port
EXPOSE 5000
# make server startup script executable and start the web server
RUN ["chmod", "+x", "/app/server/server.sh"]
ENTRYPOINT [ "/app/server/server.sh"]
this is server.sh file:
#!/bin/bash
# Set the port
PORT=5000
# Stop any program currently running on the set port
echo 'preparing port' $PORT '...'
fuser -k 5000/tcp
# switch directories
cd build/web/
# Start the server
echo 'Server starting on port' $PORT '...'
python3 -m http.server $PORT
So here is the thing. I think there are some problems with his code. As I tried to build with his code yesterday but things weren't working as they should be. I spend 2hours with his code of which 50% was spent on building the image but it was never completed. No problem I tried to modify some things and I am sharing some code with you on GitHub https://github.com/ash-0001/fludino.git. Just keep learning and sharing. Good Is Image.
The final image looks like this:
You have to use two commands to initialize this:
Before that move into the directory with your cmd
docker build -t flut .
docker run -i -p 808:4040 -td flut

How inject URL while creating flutter build web using docker

I am trying to inject URL while creating flutter build web. For Inject URL I am using environment variable. Docker file success fully create the docker image and docker container. But when I open web application on browser the environment variable is empty. I did not understand what I am missing. Previously I have no experience with docker That was my first time. Please Guide me what I am doing wrong.
To build docker image I am using command.
docker build . -t test-application
To run docker container I using command
docker run -ti -p 5000:4040 -e API_URL=example.com test-application
My docker file.
# Install dependencies
FROM debian:latest AS build-env
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 psmisc
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git -b stable /usr/local/flutter
# Set flutter path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Enable flutter web
# RUN flutter channel stable
# RUN flutter upgrade
# RUN flutter config --enable-web
# Run flutter doctor
RUN flutter doctor -v
# Copy the app files to the container
COPY . /usr/local/bin/app
# Set the working directory to the app files within the container
WORKDIR /usr/local/bin/app
# Get App Dependencies
RUN flutter clean
# Get App Dependencies
RUN flutter pub get
# Build the app for the web
RUN flutter build web --release --dart-define API_URL=${API_URL:-}
# Document the exposed port
EXPOSE 4040
# Set the server startup script as executable
RUN ["chmod", "+x", "/usr/local/bin/app/server/server.sh"]
# Start the web server
ENTRYPOINT [ "/usr/local/bin/app/server/server.sh" ]
my server.sh file
#!/bin/bash
# Welcome
echo 'Server start script initialized'
# Set the port
PORT=4040
# Kill anything that is already running on that port
echo 'Cleaning port' $PORT
fuser -k 4040/tcp
# Change directories to the release folder
cd build/web/
# Start the server
echo 'Starting server on port' $PORT
python3 -m http.server $PORT
# Exit
echo 'Server exited...'
Getting my environment variable
static const baseUrl =
"${const String.fromEnvironment("API_URL")}/public";
To use a build argument, you need to add an ARG statement in your dockerfile. To also have it available at runtime, you can add an ENV statement, that sets an environment variable with the value of the build argument
# Install dependencies
FROM debian:latest AS build-env
# Add the following two lines
ARG API_URL
ENV API_URL=$API_URL
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 psmisc
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git -b stable /usr/local/flutter
# Set flutter path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Enable flutter web
# RUN flutter channel stable
# RUN flutter upgrade
# RUN flutter config --enable-web
# Run flutter doctor
RUN flutter doctor -v
# Copy the app files to the container
COPY . /usr/local/bin/app
# Set the working directory to the app files within the container
WORKDIR /usr/local/bin/app
# Get App Dependencies
RUN flutter clean
# Get App Dependencies
RUN flutter pub get
# Build the app for the web
RUN flutter build web --release --dart-define API_URL=${API_URL:-}
# Document the exposed port
EXPOSE 4040
# Set the server startup script as executable
RUN ["chmod", "+x", "/usr/local/bin/app/server/server.sh"]
# Start the web server
ENTRYPOINT [ "/usr/local/bin/app/server/server.sh" ]
Then when you build, you add the value you want like this
docker build --build-arg API_URL=example.com -t test-application .
You then don't need to specify it at runtime unless you want to override it, so your run command becomes. Overriding it will only override the environment variable and won't change what was put into the image at build time, of course.
docker run -ti -p 5000:4040 test-application

How to build an image of Postgres:11 with HLL extension?

I want to make a Dockerfile to build an image of Postgres:11 that already installed postgresql-hll extension inside.
Im not experienced with Docker so Im have no idea to follow the instruction of installing this extension properly.
In order to do this you need to:
clone the git repository:
git clone https://github.com/citusdata/postgresql-hll.git
Create a file called Dockerfile (at the same level with the folder postgresql-hll created at step 1) with the contents:
ARG psversion=11
FROM postgres:$psversion
COPY postgresql-hll /postgresql-hll
RUN apt-get update -y && apt-get install -y postgresql-server-dev-${PG_MAJOR} make gcc g++
WORKDIR /postgresql-hll
RUN PG_CONFIG=/usr/bin/pg_config make
RUN PG_CONFIG=/usr/bin/pg_config make install
RUN echo "shared_preload_libraries = 'hll'" >> /usr/share/postgresql/postgresql.conf.sample
COPY create_extension.sql /docker-entrypoint-initdb.d/
Create a file create_extension.sql at the same level with the Dockerfile, with the contents:
CREATE EXTENSION hll;
Build your image:
# build for POSTGRES 11
docker build -t hll:1.0 --build-arg psversion=11 .
# build for POSTGRES 9.6
docker build -t hll:1.0 --build-arg psversion=9 .
NOTE: The version for POSTGRES 9.6 gives an error when trying to load the library. It is here for completeness and maybe somebody can contribute to fix it.
Run a container based on this image
docker run -d --name hll hll:1.0
Open a shell in the newly created container:
docker exec -ti hll bash
Inside the container run:
su postgres
psql
\dx
The output should show the hll extension as installed.

Docker container for app tests with postgres database

I'm new to Docker.
I'm trying to run my node app tests in a Docker container.
I want to run the tests with a real postgres db.
I'm creating this container with the following Dockerfile:
# Set image
FROM postgres:alpine
# Install node latest
RUN apk add --update nodejs nodejs-npm
# Set working dir
WORKDIR .
# Copy the current directory contents into the container at .
ADD src src
ADD .env.testing .env
ADD package.json .
ADD package-lock.json .
# Run tests
CMD npm install && npm run coverage
From the image docs, when I run the container with:
$ docker run build-name -d postgres
I see that the container takes time to start postgresql service.
When I run the container without the "-d postgres" param:
$ docker run build-name
The service does not start and the tests fail due to "could not connect to server".
Questions:
A. How can I run the tests AFTER the postgresql service starts?
B. I saw some examples using docker-composer but can I do this without composer?
Thanks
Thanks to #Bogdan I found the complete solution:
Dockerfile should be:
# Set image
FROM postgres:alpine
# Install node latest
RUN apk add --update nodejs nodejs-npm
# Set working dir
WORKDIR .
# Copy the current directory contents into the container at .
ADD src src
ADD .env.testing .env
ADD package.json .
ADD package-lock.json .
# Install
RUN npm install
# Init container
CMD psql -U postgres -c "SELECT 1;" postgres
Build container:
$ docker build -t test .
Run container:
$ docker run --name startedtest -d test -d postgres
Run tests after conatiner is running:
$ docker exec startedtest some_create_schema_script && npm run coverage
If the goal is just to run the tests in the Postgres container, one solution could be to install NodeJs in your postgres:alpine derived image and run the container normally. Once the database is up, you can run npm using docker exec like this:
docker exec <container_id> npm run coverage