From 34d4af1fb3fef49781e7b8fd1bfe8f7ad7e85120 Mon Sep 17 00:00:00 2001 From: jdenquin Date: Tue, 17 Sep 2024 17:17:17 +0200 Subject: [PATCH] add api --- Dockerfile | 89 +++++++------------ docker/rootfs/etc/s6-overlay/s6-rc.d/api/run | 3 + .../rootfs/etc/s6-overlay/s6-rc.d/api}/type | 0 .../rootfs/etc/s6-overlay/s6-rc.d/front/run | 6 +- .../s6-overlay/s6-rc.d/user/contents.d/api | 0 rootfs/etc/s6-overlay/s6-rc.d/testing/run | 3 - 6 files changed, 37 insertions(+), 64 deletions(-) create mode 100644 docker/rootfs/etc/s6-overlay/s6-rc.d/api/run rename {rootfs/etc/s6-overlay/s6-rc.d/testing => docker/rootfs/etc/s6-overlay/s6-rc.d/api}/type (100%) rename rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/testing => docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/api (100%) delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/testing/run diff --git a/Dockerfile b/Dockerfile index c590f29..f9db1a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,71 +1,33 @@ ARG NODE_VERSION=20 ARG RUBY_VERSION=3.3.4 -# # Front Build -# FROM node:$NODE_VERSION-alpine as front_build +# Front Build +FROM node:$NODE_VERSION-alpine as front_build -# WORKDIR /app +WORKDIR /app -# COPY ./front . +COPY ./front/ . -# RUN apk add python3 build-base -# RUN yarn && yarn build && npm prune --production +RUN apk add python3 build-base +RUN yarn && yarn build && npm prune --omit=dev # # API Build -# FROM ruby:$RUBY_VERSION-slim as api_build +FROM ruby:$RUBY_VERSION-slim as api_build -# WORKDIR /app +WORKDIR /app -# COPY ./api/Gemfile ./Gemfile -# COPY ./api/Gemfile.lock ./Gemfile.lock +COPY ./api/Gemfile ./Gemfile +COPY ./api/Gemfile.lock ./Gemfile.lock -# RUN apt update -qq && apt install build-essential git pkg-config libpq-dev curl -y -# ENV BUNDLER_VERSION='2.5.5' -# ENV RAILS_ENV=production -# RUN gem install bundler --no-document -v '2.5.5' -# RUN bundle config build.nokogiri --use-system-libraries &&\ -# bundle install --jobs=3 --retry=3 --without development test +RUN apt update -qq && apt install build-essential git pkg-config libpq-dev curl -y +ENV BUNDLER_VERSION='2.5.5' +ENV RAILS_ENV=production +RUN gem install bundler --no-document -v '2.5.5' +RUN bundle config build.nokogiri --use-system-libraries &&\ + bundle install --jobs=3 --retry=3 --without development test # Final Image -# FROM ruby:$RUBY_VERSION-slim -# ARG S6_OVERLAY_VERSION=3.2.0.0 - -# #RUN apt-get update -qq && apt-get install -y curl gnupg2 -# #RUN curl http://nginx.org/keys/nginx_signing.key | apt-key add - -# RUN apt-get update -qq && \ -# apt-get install -y nginx xz-utils -# # apt-get remove --purge -y gnupg2 && \ -# # apt-get clean && \ -# # rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man - -# ADD https://github.com/just-containers/s6-overlay/releases/download/v$S6_OVERLAY_VERSION/s6-overlay-noarch.tar.xz /tmp -# RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz -# ADD https://github.com/just-containers/s6-overlay/releases/download/v$S6_OVERLAY_VERSION/s6-overlay-x86_64.tar.xz /tmp -# RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz -# RUN rm -rf /tmp/s6-overlay-*.tar.xz - -# COPY ./docker/rootfs / - -# WORKDIR /app - -# COPY --from=front_build /app/dist /usr/share/nginx/html -# COPY --from=api_build /usr/local/bundle/ /usr/local/bundle - -# COPY ./front/.env.sh ./front/.env.sh -# COPY ./api ./api - -# RUN bash -c ./front/.env.sh - -# COPY ./front/nginx/nginx.conf /etc/nginx/sites-enabled/default - -# ENV RAILS_ENV=production - -# EXPOSE 80 -# EXPOSE 3000 - -# ENTRYPOINT ["/init"] - -FROM ruby:3.3.4-slim +FROM ruby:$RUBY_VERSION-slim ARG S6_OVERLAY_VERSION=3.2.0.0 WORKDIR /app @@ -78,7 +40,20 @@ RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz -COPY rootfs / +COPY docker/rootfs / +COPY ./front/nginx/nginx.conf /etc/nginx/sites-enabled/default + +COPY --from=front_build /app/dist /usr/share/nginx/html +COPY --from=api_build /usr/local/bundle/ /usr/local/bundle + +COPY ./front/.env.sh ./front/.env.sh +COPY ./api ./api + +RUN bash -c ./front/.env.sh + +ENV RAILS_ENV=production + +EXPOSE 80 +EXPOSE 3000 ENTRYPOINT ["/init"] - diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/api/run b/docker/rootfs/etc/s6-overlay/s6-rc.d/api/run new file mode 100644 index 0000000..f2d3170 --- /dev/null +++ b/docker/rootfs/etc/s6-overlay/s6-rc.d/api/run @@ -0,0 +1,3 @@ +#!/command/execlineb -P +cd /app/api +./scripts/start.sh \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/testing/type b/docker/rootfs/etc/s6-overlay/s6-rc.d/api/type similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/testing/type rename to docker/rootfs/etc/s6-overlay/s6-rc.d/api/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/front/run b/docker/rootfs/etc/s6-overlay/s6-rc.d/front/run index 2f81d05..0fa5fa3 100644 --- a/docker/rootfs/etc/s6-overlay/s6-rc.d/front/run +++ b/docker/rootfs/etc/s6-overlay/s6-rc.d/front/run @@ -1,4 +1,2 @@ -#!/command/with-contenv bash -# shellcheck shell=bash - -nginx -g "daemon off;" +#!/command/execlineb -P +nginx \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/testing b/docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/api similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/testing rename to docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/api diff --git a/rootfs/etc/s6-overlay/s6-rc.d/testing/run b/rootfs/etc/s6-overlay/s6-rc.d/testing/run deleted file mode 100644 index 91dfe76..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/testing/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/command/with-contenv bash - -nginx -g "daemon off;"