Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Multistage build
Browse files Browse the repository at this point in the history
  • Loading branch information
zhulik committed Jan 15, 2023
1 parent 1a3a3f5 commit be2cf48
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 36 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

41 changes: 17 additions & 24 deletions hass-listener/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
# TODO: mulstistage build
FROM openfaas/of-watchdog:0.8.2 as watchdog

FROM ruby:3.2.0-slim-buster

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog

RUN apt-get update &&\
apt-get install -qy --no-install-recommends build-essential

RUN mkdir -p /home/app/function

WORKDIR /home/app/function

RUN addgroup --system app &&\
adduser --system --ingroup app app

RUN chown app:app -R /home/app

USER app
FROM ruby:3.2.0-slim as base

RUN adduser app
WORKDIR /mnt
RUN bundle config --local path vendor/bundle
EXPOSE 8080

HEALTHCHECK --interval=2s CMD curl -f http://127.0.0.1:4567/healthcheck

ENV fprocess="ruby index.rb"
ENV fprocess="bundle exec ruby index.rb"
ENV upstream_url="http://127.0.0.1:4567"
ENV mode="http"
ENV APP_ENV="production"

CMD ["fwatchdog"]

COPY function/Gemfile .
FROM base as builder

RUN apt-get update &&\
apt-get install -qy --no-install-recommends build-essential
COPY function/Gemfile .
RUN bundle install


FROM openfaas/of-watchdog:0.8.2 as watchdog
FROM base

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog
COPY --from=builder /mnt/ .
COPY function .
USER app
2 changes: 1 addition & 1 deletion hass-listener/function/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

gem "sinatra", "~> 3"
gem "sinatra", "~> 3.0"
gem "falcon", "~> 0.42"
2 changes: 1 addition & 1 deletion hass-listener/function/index.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "sinatra"

require_relative "handler"
require_relative "lib/handler"

handler = Handler.new

Expand Down
File renamed without changes.
9 changes: 0 additions & 9 deletions stack.yml

This file was deleted.

0 comments on commit be2cf48

Please sign in to comment.