-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Loongson-Cloud-Community:main' into main
- Loading branch information
Showing
16 changed files
with
1,056 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
FROM lcr.loongnix.cn/library/alpine:3.19 AS builder | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
############################################################### | ||
# set build args | ||
############################################################### | ||
ARG CURL_RELEASE_TAG=latest | ||
ARG CURL_GIT_REPO=https://github.com/curl/curl.git | ||
ARG CURL_CONFIGURE_OPTION=--without-ssl | ||
ARG LABEL_VERSION=1.0.0 | ||
ARG LABEL_NAME=curl | ||
ARG LABEL_DESC=curl | ||
|
||
############################################################### | ||
# build curl | ||
############################################################### | ||
# install deps and use latest curl release source | ||
RUN apk update && apk add libssh2 libssh2-dev libssh2-static \ | ||
autoconf automake build-base \ | ||
groff openssl curl-dev \ | ||
python3 python3-dev \ | ||
libtool curl tlstunnel perl \ | ||
nghttp2 brotli brotli-dev | ||
|
||
RUN mkdir /src | ||
COPY "curl" "/src/curl" | ||
WORKDIR /src/curl | ||
|
||
############################################################### | ||
# get ca cert bundle from curl.haxx.se | ||
############################################################### | ||
RUN curl https://curl.haxx.se/ca/cacert.pem -L -o /cacert.pem | ||
|
||
############################################################### | ||
# build the tag version | ||
############################################################### | ||
RUN ./buildconf && \ | ||
autoreconf -vif && \ | ||
./configure ${CURL_CONFIGURE_OPTION} &&\ | ||
make -j$(nproc) &&\ | ||
#make test &&\ | ||
make DESTDIR="/alpine/" install -j$(nproc) | ||
|
||
############################################################### | ||
# pinning image to Alpine 3.11.11 | ||
############################################################### | ||
FROM lcr.loongnix.cn/library/alpine:3.19 | ||
|
||
ARG CURL_RELEASE_TAG=latest | ||
ARG CURL_RELEASE_VERSION | ||
ARG CURL_GIT_REPO=https://github.com/curl/curl.git | ||
|
||
ENV CURL_VERSION ${CURL_RELEASE_VERSION} | ||
ENV CURL_RELEASE_TAG ${CURL_RELEASE_TAG} | ||
ENV CURL_GIT_REPO ${CURL_GIT_REPO} | ||
|
||
############################################################### | ||
# dependencies | ||
############################################################### | ||
RUN apk update && \ | ||
apk add --no-cache brotli brotli-dev libssh2 nghttp2-dev && \ | ||
rm -fr /var/cache/apk/* | ||
|
||
############################################################### | ||
# add non privileged curl user | ||
############################################################### | ||
RUN addgroup -S curl_group && adduser -S curl_user -G curl_group | ||
|
||
############################################################### | ||
# set curl ca bundle | ||
############################################################### | ||
COPY --from=builder "/cacert.pem" "/cacert.pem" | ||
ENV CURL_CA_BUNDLE="/cacert.pem" | ||
|
||
############################################################### | ||
# install curl built from builder | ||
############################################################### | ||
COPY --from=builder "/alpine/usr/local/lib/libcurl.so.4.8.0" "/usr/lib/" | ||
COPY --from=builder "/alpine/usr/local/bin/curl" "/usr/bin/curl" | ||
COPY --from=builder "/alpine/usr/local/include/curl" "/usr/include/curl" | ||
|
||
# explicitly set symlinks | ||
RUN ln -s /usr/lib/libcurl.so.4.8.0 /usr/lib/libcurl.so.4 | ||
RUN ln -s /usr/lib/libcurl.so.4 /usr/lib/libcurl.so | ||
|
||
############################################################### | ||
# set user | ||
############################################################### | ||
USER curl_user | ||
|
||
############################################################### | ||
# set entrypoint | ||
############################################################### | ||
COPY "entrypoint.sh" "/entrypoint.sh" | ||
CMD ["curl"] | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This file is generated by the template. | ||
|
||
REGISTRY?=lcr.loongnix.cn | ||
ORGANIZATION?=curlimages | ||
REPOSITORY?=curl | ||
TAG?=latest | ||
|
||
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) | ||
|
||
CURL_RELEASE_TAG?=curl-8_7_1 | ||
CURL_GIT_REPO?=https://github.com/curl/curl.git | ||
|
||
default: image | ||
|
||
image: source replace build | ||
|
||
|
||
source: clear | ||
git clone --branch $(CURL_RELEASE_TAG) $(CURL_GIT_REPO) | ||
|
||
TARGET_FILE_PATH:=curl/lib | ||
TARGET_FILE:=easy_lock.h | ||
|
||
replace: | ||
rm $(TARGET_FILE_PATH)/$(TARGET_FILE) | ||
cp $(TARGET_FILE) $(TARGET_FILE_PATH)/ | ||
|
||
build: | ||
docker build --no-cache \ | ||
-t $(IMAGE) \ | ||
. | ||
|
||
push: | ||
docker push $(IMAGE) | ||
|
||
clear: | ||
rm -rf curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al. | ||
* | ||
* This software is licensed as described in the file COPYING, which | ||
* you should have received as part of this distribution. The terms | ||
* are also available at https://curl.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
* SPDX-License-Identifier: curl | ||
* | ||
***************************************************************************/ | ||
|
||
#include "curl_setup.h" | ||
|
||
#define GLOBAL_INIT_IS_THREADSAFE | ||
|
||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 | ||
|
||
#define curl_simple_lock SRWLOCK | ||
#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT | ||
|
||
#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) | ||
#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) | ||
|
||
#elif defined (HAVE_ATOMIC) | ||
#include <stdatomic.h> | ||
|
||
#define curl_simple_lock atomic_bool | ||
#define CURL_SIMPLE_LOCK_INIT false | ||
|
||
static inline void curl_simple_lock_lock(curl_simple_lock *lock) | ||
{ | ||
for(;;) { | ||
if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) | ||
break; | ||
/* Reduce cache coherency traffic */ | ||
while(atomic_load_explicit(lock, memory_order_relaxed)) { | ||
/* Reduce load (not mandatory) */ | ||
#if defined(__i386__) || defined(__x86_64__) | ||
__builtin_ia32_pause(); | ||
#elif defined(__aarch64__) | ||
asm volatile("yield" ::: "memory"); | ||
#elif defined(HAVE_SCHED_YIELD) | ||
#include<sched.h> // sched_yield(); | ||
#endif | ||
} | ||
} | ||
} | ||
|
||
static inline void curl_simple_lock_unlock(curl_simple_lock *lock) | ||
{ | ||
atomic_store_explicit(lock, false, memory_order_release); | ||
} | ||
|
||
#else | ||
|
||
#undef GLOBAL_INIT_IS_THREADSAFE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (C) 2020 James Fuller <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
set -e | ||
|
||
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then | ||
set -- curl "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
FROM lcr.loongnix.cn/library/alpine:3.19 | ||
|
||
RUN apk add --no-cache ca-certificates | ||
|
||
# set up nsswitch.conf for Go's "netgo" implementation | ||
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 | ||
# - docker run --rm debian grep '^hosts:' /etc/nsswitch.conf | ||
#RUN [ ! -e /echo/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf | ||
|
||
ENV PATH /usr/local/go/bin:$PATH | ||
|
||
ENV GOLANG_VERSION 1.20.12 | ||
|
||
# Bootstrap for Go1.20 requires minimum Go1.17, now build Go1.19 as bootstrap for Go1.20.x | ||
RUN set -eux; \ | ||
build=1; \ | ||
url='http://ftp.loongnix.cn/toolchain/golang/go-1.19/abi2.0/go1.19.7.src.tar.gz'; \ | ||
sha256='cf3d38154f15b64d141800e3a98dbd73df7c829eec87ebe2df1d5c7c93013206'; \ | ||
export GOARCH='loong64' GOOS='linux'; \ | ||
\ | ||
wget -O go.tgz "$url"; \ | ||
echo "$sha256 *go.tgz" | sha256sum -c -; \ | ||
\ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz; \ | ||
\ | ||
apk add --no-cache --virtual .build-deps bash gcc go musl-dev; \ | ||
\ | ||
cd /usr/local/go/src; \ | ||
export GOCACHE='/tmp/gocache'; \ | ||
export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \ | ||
./make.bash; \ | ||
\ | ||
cd ../../ && mv go go-bootstrap; \ | ||
rm -rf "$GOCACHE"; \ | ||
\ | ||
/usr/local/go-bootstrap/bin/go version | ||
|
||
|
||
RUN set -eux; \ | ||
build=1; \ | ||
# https://github.com/golang/go/issues/38536#issuecomment-616897960 | ||
url='http://ftp.loongnix.cn/toolchain/golang/go-1.20/abi2.0/go1.20.12.src.tar.gz'; \ | ||
sha256='383b02b0f59e47d04cee0dd7bd0b98e0c960fa038e633f0067cc009db98f05cd'; \ | ||
export GOARCH='loong64' GOOS='linux'; \ | ||
\ | ||
wget -O go.tgz "$url"; \ | ||
echo "$sha256 *go.tgz" | sha256sum -c -; \ | ||
\ | ||
tar -C /usr/local -xzf go.tgz; \ | ||
rm go.tgz; \ | ||
\ | ||
if [ -n "$build" ]; then \ | ||
apk add --no-cache --virtual .build-deps \ | ||
bash \ | ||
gcc \ | ||
go \ | ||
musl-dev \ | ||
; \ | ||
\ | ||
export GOCACHE='/tmp/gocache'; \ | ||
\ | ||
( \ | ||
cd /usr/local/go/src; \ | ||
# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully | ||
export GOROOT_BOOTSTRAP="/usr/local/go-bootstrap" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \ | ||
if [ "${GOARCH:-}" = '386' ]; then \ | ||
# https://github.com/golang/go/issues/52919; https://github.com/docker-library/golang/pull/426#issuecomment-1152623837 | ||
export CGO_CFLAGS='-fno-stack-protector'; \ | ||
fi; \ | ||
./make.bash; \ | ||
); \ | ||
\ | ||
apk del --no-network .build-deps; \ | ||
\ | ||
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain | ||
rm -rf \ | ||
/usr/local/go/pkg/*/cmd \ | ||
/usr/local/go/pkg/bootstrap \ | ||
/usr/local/go/pkg/obj \ | ||
/usr/local/go/pkg/tool/*/api \ | ||
/usr/local/go/pkg/tool/*/go_bootstrap \ | ||
/usr/local/go/src/cmd/dist/dist \ | ||
"$GOCACHE" \ | ||
/usr/local/go-bootstrap \ | ||
; \ | ||
fi; \ | ||
\ | ||
go version | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$PATH | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
WORKDIR $GOPATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file is generated by the template. | ||
|
||
REGISTRY ?= lcr.loongnix.cn | ||
ORGANIZATION ?= library | ||
REPOSITORY ?= golang | ||
TAG ?= 1.20-alpine | ||
|
||
IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) | ||
|
||
default: image | ||
|
||
image: | ||
docker build \ | ||
-t $(IMAGE) \ | ||
. | ||
|
||
push: | ||
docker push $(IMAGE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.