Skip to content

Commit

Permalink
Move to Alpine to fix the strange httpd error
Browse files Browse the repository at this point in the history
This commit does the following:
- Use Alpine 3.18 as a base for building container images
- Modify the Apache config files to match what comes with Alpine
- The PID file is now in /var/run/apache2
- Remove deprecated statements from docker-compose.yml and Dockerfile(s)
- Had to make a small change to cert.go. Don't know why. Worked before?
  • Loading branch information
oyvindhagberg committed Nov 7, 2024
1 parent 17a02cb commit 06bebef
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 66 deletions.
22 changes: 12 additions & 10 deletions ci/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
FROM fedora:latest
FROM alpine:3.18
EXPOSE 80 443
LABEL no.uio.contact=usit-gid@usit.uio.no
LABEL no.uio.contact=usit-dia@usit.uio.no
LABEL description="Web server for Nivlheim"
ARG BRANCH=""

RUN dnf install -y httpd mod_ssl procps-ng \
unzip file bind-utils npm \
&& dnf install -y --releasever=39 openssl \
&& dnf clean all \
&& rm -rf /var/cache/yum \
&& npm install -g handlebars
RUN apk update && apk upgrade \
&& apk add apache2 apache2-ssl apache2-utils apache2-proxy procps-ng unzip file bind-tools npm bash curl \
&& apk add openssl1.1-compat && rm /usr/bin/openssl && ln /usr/bin/openssl1.1 /usr/bin/openssl \
&& rm -rf /var/cache/apk/*
RUN npm install -g handlebars

# config
COPY server/openssl_ca.conf /etc/nivlheim/
COPY server/client_CA_cert.sh /usr/bin/
COPY server/httpd_ssl.conf /etc/httpd/conf.d/ssl.conf
COPY server/httpd.conf /etc/httpd/conf/httpd.conf
COPY server/httpd_ssl.conf /etc/apache2/conf.d/ssl.conf
COPY server/httpd.conf /etc/apache2/httpd.conf

# before moving to Alping we used this log directory so let's continue with that
RUN mkdir /var/log/httpd

# copy the static web content
COPY server/website /var/www/html/
Expand Down
9 changes: 4 additions & 5 deletions ci/docker/api_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ COPY server/service/*.go ./
COPY server/service/database ./database
COPY server/service/utility ./utility

RUN go build -o /nivlheim -ldflags "-X main.version=${version:-UNDEFINED}"
RUN CGO_ENABLED=0 go build -o /nivlheim -ldflags "-X main.version=${version:-UNDEFINED}"

## Deploy
FROM ubuntu:latest
MAINTAINER [email protected]
LABEL [email protected]
FROM alpine:3.18
LABEL [email protected]
LABEL description="Main Nivlheim server exposing API"

EXPOSE 4040

WORKDIR /

RUN apt-get update -qq && apt-get install -yqq ca-certificates
RUN apk --no-cache add ca-certificates
COPY --from=build /nivlheim /nivlheim
COPY server/server.conf /etc/nivlheim/server.conf

Expand Down
1 change: 0 additions & 1 deletion ci/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
nivlheimweb:
container_name: docker-nivlheimweb-1
Expand Down
4 changes: 2 additions & 2 deletions server/client_CA_cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ if [[ $ACTIVATE -eq 1 ]]; then
mv new_nivlheimca.csr nivlheimca.csr
mv new_nivlheimca.crt nivlheimca.crt
# signal httpd to gracefully restart, if it is running
if [[ -f /var/run/httpd/httpd.pid ]]; then
kill -usr1 `cat /var/run/httpd/httpd.pid`
if [[ -f /var/run/apache2/httpd.pid ]]; then
kill -usr1 `cat /var/run/apache2/httpd.pid`
fi
else
echo "There's no new CA certificate to activate"
Expand Down
2 changes: 1 addition & 1 deletion server/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fi
function sigterm()
{
echo "Received SIGTERM"
kill -term `cat /var/run/httpd/httpd.pid`
kill -term `cat /var/run/apache2/httpd.pid`
}
trap sigterm SIGTERM

Expand Down
Loading

0 comments on commit 06bebef

Please sign in to comment.