diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml new file mode 100644 index 00000000..83280761 --- /dev/null +++ b/.github/workflows/alpine.yml @@ -0,0 +1,28 @@ +name: Build on alpine + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker images + uses: docker/build-push-action@v6 + with: + file: docker/alpine/Dockerfile_alpine + load: true + cache-from: type=gha,scope=cgimap:alpine + cache-to: type=gha,mode=max,scope=cgimap:alpine + tags: cgimap:alpine + + - name: Running Docker image + run: | + docker run --entrypoint /bin/sh cgimap:alpine -c "/usr/local/bin/openstreetmap-cgimap --help" + diff --git a/contrib/sjparser/library/sjparser/internals/token_parser.h b/contrib/sjparser/library/sjparser/internals/token_parser.h index ad5c15a6..ef2cdf3f 100644 --- a/contrib/sjparser/library/sjparser/internals/token_parser.h +++ b/contrib/sjparser/library/sjparser/internals/token_parser.h @@ -23,6 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #pragma once +#include #include #include #include diff --git a/docker/alpine/Dockerfile_alpine b/docker/alpine/Dockerfile_alpine new file mode 100644 index 00000000..d702c83e --- /dev/null +++ b/docker/alpine/Dockerfile_alpine @@ -0,0 +1,72 @@ +FROM alpine:latest AS builder + +RUN apk update && \ + apk add g++ cmake make pkgconf libpq-dev ccmake brotli-dev \ + boost1.84-program_options libmemcached-dev yajl-dev crypto++-dev \ + fmt-dev zlib-dev fcgi-dev libxml2-dev boost-dev postgresql16 + +WORKDIR /app + +# Build and install libpqxx 7.9.2 +RUN wget https://github.com/jtv/libpqxx/archive/refs/tags/7.9.2.zip && \ + unzip 7.9.2.zip && \ + cd libpqxx-7.9.2 && \ + mkdir build && \ + cd build && \ + cmake -DSKIP_PQXX_STATIC=OFF -DSKIP_PQXX_SHARED=ON .. && \ + make -j${nproc} && \ + make install && \ + cd ../.. + +# Copy the main application. +COPY . ./ + +# Compile, install source +RUN mkdir build && cd build && \ + CXXFLAGS="-flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" cmake .. -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release && \ + make -j${nproc} && \ + ctest --output-on-failure -E "db" && \ + make install + +FROM alpine:latest + +COPY --from=builder /usr/local/bin/openstreetmap-cgimap /usr/local/bin/openstreetmap-cgimap + +RUN apk update && \ + apk add --no-cache libpq boost1.84-program_options fcgi libxml2 libmemcached brotli-libs yajl crypto++ coreutils + +ENV USER=cgimap +ENV GROUPNAME=$USER +ENV UID=60000 +ENV GID=60000 + +RUN addgroup \ + --gid "$GID" \ + "$GROUPNAME" \ +&& adduser \ + --disabled-password \ + --gecos "" \ + --home "$(pwd)" \ + --ingroup "$GROUPNAME" \ + --no-create-home \ + --uid "$UID" \ + $USER + +USER $USER + +ENV CGIMAP_HOST=db \ + CGIMAP_DBNAME=openstreetmap \ + CGIMAP_USERNAME=openstreetmap \ + CGIMAP_PASSWORD=openstreetmap \ + CGIMAP_MEMCACHE=memcached \ + CGIMAP_RATELIMIT=204800 \ + CGIMAP_MAXDEBT=250 \ + CGIMAP_MODERATOR_RATELIMIT=1048576 \ + CGIMAP_MODERATOR_MAXDEBT=1024 \ + CGIMAP_PORT=8000 \ + CGIMAP_INSTANCES=10 + +EXPOSE 8000 + +ENTRYPOINT /usr/local/bin/openstreetmap-cgimap --pidfile /tmp/cgimap.pid --logfile=/proc/1/fd/1 --daemon && \ + tail --pid=$(cat /tmp/cgimap.pid) -f /dev/null diff --git a/src/time.cpp b/src/time.cpp index 85cdc5c0..0a64eaf3 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -21,7 +21,7 @@ std::chrono::system_clock::time_point parse_time(const std::string &s) { // parse only YYYY-MM-DDTHH:MM:SSZ if ((s.size() == 20) && (s[19] == 'Z')) { std::tm tm{}; - strptime(s.c_str(), "%FT%T%z", &tm); + strptime(s.c_str(), "%Y-%m-%dT%H:%M:%S%z", &tm); auto tp = std::chrono::system_clock::from_time_t(timegm(&tm)); return tp;