Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alpine based Dockerfile #457

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
@@ -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"

1 change: 1 addition & 0 deletions contrib/sjparser/library/sjparser/internals/token_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#pragma once

#include <cstdint>
#include <stdexcept>
#include <string>
#include <string_view>
Expand Down
72 changes: 72 additions & 0 deletions docker/alpine/Dockerfile_alpine
Original file line number Diff line number Diff line change
@@ -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 \

Check warning on line 57 in docker/alpine/Dockerfile_alpine

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "CGIMAP_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
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 && \

Check warning on line 71 in docker/alpine/Dockerfile_alpine

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
tail --pid=$(cat /tmp/cgimap.pid) -f /dev/null
2 changes: 1 addition & 1 deletion src/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading