반응형

 

docker 명령어가 아닌 buildah를 이용하여 multiarch build 후 docker hub에 push하는 방법이다.

우선, 원활한 multiarch build를 위해 아래 글을 먼저 참고한다.

2024.04.28 - [Develop/기타 작업] - exec container process `/bin/sh`: Exec format error

 

1. manifest 생성

buildah manifest create multi-test

 

 

2. buildah 를 이용한 이미지 빌드

amd64 빌드

buildah build --arch=amd64 -f Dockerfile -t docker.io/name/multi-test:1.0 --manifest multi-test .

 

arm64 빌드

buildah build --arch=arm64 -f Dockerfile -t docker.io/name/multi-test:1.0 --manifest multi-test .

 

 

3. 잘 되었는지 manifest 조회

buildah manifest inspect multi-test
# result
{
    "schemaVersion": 2,
    "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
    "manifests": [
        {
            "mediaType": "application/vnd.oci.image.manifest.v1+json",
            "size": 498,
            "digest": "sha256:ba89775d01a87554befd5cb4067cee02a81e28fbd575e458c7da8de269251475",
            "platform": {
                "architecture": "arm64",
                "os": "linux"
            }
        },
        {
            "mediaType": "application/vnd.oci.image.manifest.v1+json",
            "size": 498,
            "digest": "sha256:1ac1ba96e89b9b2184e1b21a9bdbe22ba8c5d9e3433e692482ab53e9a816383b",
            "platform": {
                "architecture": "amd64",
                "os": "linux"
            }
        }
    ]
}

 

 

4. docker hub login

docker hub 의 ID와 PW를 이용하여 로그인

buildah login -u ID -p PW docker.io

 

 

5. docker hub 에서 생성한 repository에 push

buildah manifest push --all multi-test "docker://docker.io/name/multi-test:1.0"

 

 

6. docker hub에 접속하여 확인

반응형
반응형

 

buildah 를 이용하여 arm 아키텍처에서 amd 로 multi platform 빌드를 수행하는 도중 계속 아래와 같은 에러가 발생했다.

exec container process `/bin/sh`: Exec format error

 

docker 또는 buildah로 multi platform 빌드할 경우 아키텍처 옵션을 주면 해결된다고 하였으나, 되지않았고

qemu-user-static 을 설치해주니 잘동작하였다.

qemu-user-static 은 다양한 아키텍처를 실행해주는 소프트웨어이다.

apt-get update -y
apt-get install qemu-user-static

 

설치 후 다른 사용법은 없으며, 그냥 아키텍쳐 옵션을 주면 빌드가된다.

 buildah build --arch=amd64 -f Dockerfile -t wky.kr/test:latest .

 

또한, amd64로 이미지를 생성한 후 arm 아키텍처에서 해당 amd64 이미지 k8s에서 실행하여도

qemu-user-static 으로 인하여 실행이된다.

 

참고 : https://github.com/multiarch/qemu-user-static

https://github.com/containers/buildah/blob/main/docs/buildah-build.1.md

반응형
반응형

 

Docker 대신 image를 만들 수 있는 도구

기본적으로 Docker 명령어와 동일한 듯 하다.

 

1. install

sudo apt install buildah

 

2. build

buildah build -f Dockerfile -t fedora-httpd .
# or
buildah build -t fedora-httpd

 

3. push 

buildah push registry.example.com/my_image

 

https://github.com/containers/buildah/blob/main/docs/tutorials/01-intro.md

https://github.com/containers/buildah/blob/main/docs/buildah-push.1.md

반응형
반응형

 

1. Docker 아키텍쳐 pull

docker pull --platform linux/amd64 nginx:latest

 

2. Docker image 저장

docker save -o a.tar imagenams

 

3. Docker image 업로드

docker load -i a.tar

 

 

4. Docker image 태그 변경

docker image tag imageid a:1.0

 

반응형
반응형

 

주로 사용하던 sed 명령어들

 

1. sed 수정

sed -i 's/ver: 1.0.0/ver: 1.0.1' /home/user/test.conf

 

 

2. sed 특정 글 위에추가, 특정 글 아래 추가

특정 글 위에 추가

sed -i -r -e '/ver: 1.0.1/i\Description: version' /home/user/test.conf

 

특정글 아래 추가

sed -i -r -e '/ver: 1.0.1/a\End Of File' /home/user/test.conf

 

 

3. 특정 글 아래 수정

sed -i '/Description: version/{ n; s/ver: 1.0.1/version: 1.0.1/I}' /home/user/test.conf

 

 

4.  띄어쓰기(space) 입력

기본적으로 한줄이면 그냥 스페이스바 입력으로 되지만, 그게 아니라면 역슬래쉬(\)를 해주어야 함.

# 한 줄로 작성할 경우
sed -i -r -e '/version: 1.0.1/a\  Date: 2024' /home/user/test.conf

# 여러 줄로 작성할 경우
sed -i -r -e '/Date: 2024/a\
\ \ Month: 4(April)' /home/user/test.conf

 

 

최종 결과물

 

반응형
반응형

 

Nginx의 auth_request 기능을 사용하고 싶었지만, apache에는 이와 비슷한 기능이 없는 것 같아

AuthType이라는것을 사용하였다.

 

1. 사용전 htpasswd 확인

htpasswd는 기본적으로 Apach생성 경로의 bin폴더에 있다.

# Apache 가 /usr/local 폴더에 있을경우
/usr/local/apache/bin/htpasswd

 

bin폴더에 없을경우 httpd를 설치한다. - https://httpd.apache.org/download.cgi#apache24

 

2. htpasswd를 통해 계정과 비밀번호를 생성

-c 는 create 옵션이고 /home/test 폴더 내에 .htpasswd 파일을 생성하고

해당 파일에 user1이라는 계정과 패스워드를 관리한다

# Input
./htpasswd -c /home/test/.htpasswd user1

# Output
cat /home/test.htpasswd
user1:$apr1$.0CAabqX$rsdf8sdSDFgs/p90SDGcvb1Gs/

 

 

3. AuthType 설정

사용 중인 conf파일에 설정 후 아파치 재시작한다.

<Location "/private">

AuthType Basic
AuthName "Authentication required"
AuthUserFile /home/test/.htpasswd
Require valid-uesr

</Location>

 

 

기타.

이렇게 설정할 경우 기본적으로 웹사이트에 로그인하는 로직이 있다면 해당 세션이 끊기게되는데

아래 설정을 추가할 경우 해결할 수 있긴하다.

RequestHeader unset Authorization
<Location "/private">

AuthType Basic
AuthName "Authentication required"
AuthUserFile /home/test/.htpasswd
Require valid-uesr

</Location>

 

 

https://httpd.apache.org/docs/2.4/en/howto/auth.html

반응형
반응형

 

Java에서 Inner Class 사용시 발생하는 No enclosing instance of type is accessible 해결 방법이다.

 

아래와 같이 java 파일들이 구성되어있고 Hello.java 파일안에 World 라는 inner class가 있을 경우

public class Hello {
	private int id;

	public Hello() {
		super();
	}

	public Hello(int id) {
		super();
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public class World {		
		private String name;

		public World() {
			super();
		}

		public World(String name) {
			super();
			this.name = name;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}			
		
	}
}

 

Hello안에있는 World Class를 사용하기 위해서 Hello Class를 먼저 생성 후 World Class를 호출한다.

import test3.Hello.World;

public class Main {

	public static void main(String[] args) {

		Hello hello = new Hello();
		World world = hello.new World();
				
	}

}
반응형
반응형

Nginx에서 client에서 파일 업로드와 같은 작업 수행시

응답으로는 이미 max_client_body_size 설정으로 에러인 상황에서 Request가 중단되어야하지만

Request가 끝까지 진행되는 경우가 있는데

이 경우 send_timeout, proxy_send_timeout, proxy_connect_timeout, client_body_timeout 등의 설정이아니라

 

lingering_time으로 설정해야한다.

Syntax:	lingering_time time;
Default: lingering_time 30s;
Context: http, server, location

This directive applies to client requests with a request body. As soon as the number of uploaded data exceeds max_client_body_size, Nginx immediately sends a 413 Request entity too large HTTP error response. However, most browsers continue uploading data regardless of that notification. This directive defines the number of time Nginx should wait after sending this error response before closing the connection.

 

http://nginx.org/en/docs/http/ngx_http_core_module.html#lingering_time

https://www.oreilly.com/library/view/nginx-http-server/9781788623551/97c141a3-0e51-4786-b865-8c8770a643a5.xhtml

반응형
반응형

Nginx Error Page 처리방법으로는 error_page를 먼저 선언하고 뒤에 에러코드

그리고 표시할 html 파일 이름을 작성한 후 location을 선언한다.

location 안에는 html 파일경로를 작성한다.

또한, 한번에 여러 에러를 같은 페이지로 처리하기 위해서는 500 501 502 이런식으로 선언하여 사용한다.

server {

    error_page 400 /error_400.html;
    location = /error_400.html {
        root /usr/error/;
    }
    
    error_page 404 /error_404.html;
    location = /error_404.html {
    	root /usr/error/;
    }
    
    error_page 500 501 502 /error_500.html;
    location = /error_500.html {
    	root /usr/error/;
    }
}

 

 

간혹 에러페이지를 선언하였지만, 해당 에러페이지로 가지 않을 땐

발생하는 해당 location에 proxy_intercept_errors on;을 선언한다.

server {

	
    error_page 400 /error_400.html;
    location = /error_400.html {
        root /usr/error/;
    }
    
    error_page 404 /error_404.html;
    location = /error_404.html {
    	root /usr/error/;
    }
    
    error_page 500 501 502 /error_500.html;
    location = /error_500.html {
    	root /usr/error/;
    }
    
    location /api/test {
    	proxy_intercept_errors on;
    }
}

 

반응형
반응형

Jenknis 에서 Git Checkout 할 경우 파일 용량이 클 때 아래와 같이 기본으로 사용할 경우 10분이 넘어갈 경우 timeout 이 발생한다.

pipeline {
    agent any 
    stages {
        stage('checkout') { 
            steps {
                git branch: 'master', credentialsId: 'credentialsId', url: 'git Repo URL"
            }
        }

    }
}

 

이를 해결하기 위해 스크립트를 사용할 경우 아래와 같이 사용하여 timeout 시간을 늘려준다.

pipeline {
    agent any 
    stages {
        stage('checkout') { 
            steps {
                checkout([
                	$class: "GitSCM",
                	branche: [[name: "master"]],
                	extensions: [
                    	[$class: "CheckoutOption", timeout: 120],
                    	[$class: "CloneOption", timeout: 120]
                    ],
                	gitTool "Default",
                	userRemoteConfigs: [[credentialsId: "credentialsId", url: "git Repo URL"]]
                ])
            }
        }

    }
}

 

반응형

+ Recent posts