jitesoft / docker-lighttpd

Lighttpd alpine linux.
MIT License
9 stars 0 forks source link

[Q] - how i can restart the server through dockerfile? #4

Closed nuevakenia closed 2 years ago

nuevakenia commented 2 years ago

Hi, i cant figure out how i can reload, stop or restart the lighttpd, im shure im missing something, maybe the way i want to do things.

this is my workflow on my dockerfile:

FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package.json ./
RUN yarn install
COPY . ./
RUN yarn build

################################################################
ENV PORT=80
ENV SERVER_NAME=localhost
ENV SERVER_ROOT=/var/www/html
ENV CONFIG_FILE=/etc/lighttpd/lighttpd2.conf
ENV SKIP_HEALTHCHECK=false
ENV MAX_FDS=1024
# ##############################################
FROM jitesoft/lighttpd as deploy-stage

LABEL maintainer="daniel.galli@test123.com"

COPY --from=build-stage /app/dist /var/www/html/
WORKDIR /etc/lighttpd/
COPY lighttpd2.conf .
EXPOSE 80

After copy the file lighttpd2.conf i want to reload the server with this file as the config. i dont know if im doing everything wrong, but any clue would be apreciate. btw, this is my lighttpd2.conf

server.modules += ("mod_access", "mod_accesslog", "mod_rewrite", "mod_auth")
server.document-root = env.SERVER_ROOT
server.port = env.PORT
server.name = env.SERVER_NAME
server.username  = "www-data"
server.groupname = "www-data"
server.indexfiles = ("index.php", "index.html", "index.htm")
server.max-fds = env.MAX_FDS
static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")
url.access-deny = ("~", ".inc")
server.follow-symlink = "enable"
dir-listing.activate = "disable"

url.rewrite-if-not-file = ("/.*" => "/index.html")

basically i want to get rid of 404 errors on my vuejs3/vite website and i found this is a way.

Johannestegner commented 2 years ago

Hi!

The lighttpd service is started with the container, and is basically what keeps the container running, if you stop/restart the process, the container will restart. But I don't think you need to restart the process to load your configuration!

When it comes to your specific issue, it looks like you only change a single line in the "base" configuration, that is supplied in the image, which would be easier to add to its own configuration file. When the container starts lighttpd it uses a single configuration file which in turn loads all config files from the following two places:

"/etc/lighttpd/conf.d/*.conf"
"/usr/local/lighttpd.d/*.conf"

So if you only want to add the url.rewrite clause, I would recommend just adding that as its own config:

FROM jitesoft/lighttpd

COPY --from=build-stage /app/dist /var/www/html/
RUN echo 'url.rewrite-if-not-file = ("/.*" => "/index.html")' > /etc/lighttpd/conf.d/urlrewrite.conf

And it should load the configuration as you need it to.

nuevakenia commented 2 years ago

Thanks a lot @Johannestegner for your response and develop! i have fixed pasting my new .conf in the usr/local/lighttpd.d after is created.

i will try your code since looks lighter.

Thanks a lot!

# ##############################################
FROM jitesoft/lighttpd as deploy-stage

COPY --from=build-stage /app/dist /var/www/html/
WORKDIR /usr/local/lighttpd.d
COPY lighttpd2.conf .