diff --git a/Others/mongoose/7.20/24.03-lts-sp2/Dockerfile b/Others/mongoose/7.20/24.03-lts-sp2/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dfbb8876ebd824fbbc105454298670c061333bcc --- /dev/null +++ b/Others/mongoose/7.20/24.03-lts-sp2/Dockerfile @@ -0,0 +1,22 @@ +ARG BASE=openeuler/openeuler:24.03-lts-sp2 +FROM ${BASE} as builder +ARG VERSION=7.20 + +RUN yum install -y gcc-c++ wget && \ + yum clean all + +WORKDIR /mongoose + +COPY example.c . + +RUN wget https://github.com/cesanta/mongoose/archive/refs/tags/${VERSION}.tar.gz \ + && tar -zxvf ${VERSION}.tar.gz -C /mongoose --strip-components=1 \ + && gcc example.c mongoose.c -o server -lpthread + +FROM ${BASE} + +WORKDIR /mongoose + +COPY --from=builder /mongoose/server /mongoose/server + +CMD ["./server"] diff --git a/Others/mongoose/7.20/24.03-lts-sp2/example.c b/Others/mongoose/7.20/24.03-lts-sp2/example.c new file mode 100644 index 0000000000000000000000000000000000000000..b193e27de0fe8e1462865f6647132a47a42074f5 --- /dev/null +++ b/Others/mongoose/7.20/24.03-lts-sp2/example.c @@ -0,0 +1,38 @@ +// Copyright (c) 2013-2025 Cesanta Software Limited +// All rights reserved +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. For the terms of this +// license, see http://www.gnu.org/licenses/ +// +// You are free to use this software under the terms of the GNU General +// Public License, but WITHOUT ANY WARRANTY; without even the implied +// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// Alternatively, you can license this software under a commercial +// license, as set out in https://www.mongoose.ws/licensing/ +// +// SPDX-License-Identifier: GPL-2.0-only or commercial + +#include "mongoose.h" // To build, run: cc main.c mongoose.c + +// HTTP server event handler function +void ev_handler(struct mg_connection *c, int ev, void *ev_data) { + if (ev == MG_EV_HTTP_MSG) { + struct mg_http_message *hm = (struct mg_http_message *) ev_data; + struct mg_http_serve_opts opts = { .root_dir = "./web_root/" }; + mg_http_serve_dir(c, hm, &opts); + } +} + +int main(void) { + struct mg_mgr mgr; // Declare event manager + mg_mgr_init(&mgr); // Initialise event manager + mg_http_listen(&mgr, "http://0.0.0.0:8000", ev_handler, NULL); // Setup listener + for (;;) { // Run an infinite event loop + mg_mgr_poll(&mgr, 1000); + } + return 0; +} \ No newline at end of file diff --git a/Others/mongoose/README.md b/Others/mongoose/README.md index aea8a061802e2df39713e4b8c534b71f767c411c..dcebcfed87f50a0197345cee056b5f14ffd05524 100644 --- a/Others/mongoose/README.md +++ b/Others/mongoose/README.md @@ -17,6 +17,7 @@ The tag of each mongoose docker image is consist of the version of mongoose and | Tags | Currently | Architectures | |---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|---------------| +|[7.20-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/7.20/24.03-lts-sp2/Dockerfile) | mongoose 7.20 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [5.1-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/5.1/24.03-lts-sp1/Dockerfile) | Mongoose 5.1 on openEuler 24.03-LTS-SP1 | amd64, arm64 | | [7.18-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/7.18/24.03-lts-sp2/Dockerfile) | Mongoose 7.18 on openEuler 24.03-LTS-SP2 | amd64, arm64 | diff --git a/Others/mongoose/doc/image-info.yml b/Others/mongoose/doc/image-info.yml index ee80d6f827e5f1d166f9cebbba2a54528dd43318..ff47cdf855f0813c92986ed82c7f59b62d76d3d4 100644 --- a/Others/mongoose/doc/image-info.yml +++ b/Others/mongoose/doc/image-info.yml @@ -11,6 +11,7 @@ tags: | | Tags | Currently | Architectures | |---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|---------------| + |[7.20-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/7.20/24.03-lts-sp2/Dockerfile) | mongoose 7.20 on openEuler 24.03-LTS-SP2 | amd64, arm64 | | [5.1-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/5.1/24.03-lts-sp1/Dockerfile) | Mongoose 5.1 on openEuler 24.03-LTS-SP1 | amd64, arm64 | | [7.18-oe2403sp2](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/mongoose/7.18/24.03-lts-sp2/Dockerfile) | Mongoose 7.18 on openEuler 24.03-LTS-SP2 | amd64, arm64 | diff --git a/Others/mongoose/meta.yml b/Others/mongoose/meta.yml index ca299e07b800e11130e1b9418e02b6c7e52ca353..4e2c52bd4029eaa900152d6f73e41617de008b36 100644 --- a/Others/mongoose/meta.yml +++ b/Others/mongoose/meta.yml @@ -1,4 +1,6 @@ 5.1-oe2403sp1: path: 5.1/24.03-lts-sp1/Dockerfile 7.18-oe2403sp2: - path: 7.18/24.03-lts-sp2/Dockerfile \ No newline at end of file + path: 7.18/24.03-lts-sp2/Dockerfile +7.20-oe2403sp2: + path: 7.20/24.03-lts-sp2/Dockerfile \ No newline at end of file