Skip to content

Commit

Permalink
Added alpine dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed Jan 4, 2025
1 parent f96b20f commit 070a5c6
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
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"
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

0 comments on commit 070a5c6

Please sign in to comment.