Skip to content

Commit

Permalink
Merge branch 'Loongson-Cloud-Community:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxuhui authored Apr 7, 2024
2 parents ed6e8bf + 00ba79b commit 9bb4848
Show file tree
Hide file tree
Showing 16 changed files with 1,056 additions and 1 deletion.
99 changes: 99 additions & 0 deletions curlimages/curl/8.7.1/Dockerfile
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"]


37 changes: 37 additions & 0 deletions curlimages/curl/8.7.1/Makefile
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
71 changes: 71 additions & 0 deletions curlimages/curl/8.7.1/easy_lock.h
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
14 changes: 14 additions & 0 deletions curlimages/curl/8.7.1/entrypoint.sh
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 "$@"
94 changes: 94 additions & 0 deletions library/golang/1.20-alpine/Dockerfile
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
19 changes: 19 additions & 0 deletions library/golang/1.20-alpine/Makefile
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)

2 changes: 1 addition & 1 deletion library/golang/1.21-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lcr.loongnix.cn/library/alpine:v3.18-base
FROM lcr.loongnix.cn/library/alpine:3.19

RUN apk add --no-cache ca-certificates

Expand Down
Loading

0 comments on commit 9bb4848

Please sign in to comment.