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;"