-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cc14fc
commit 656a0c5
Showing
1 changed file
with
41 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
FROM ruby:3.4.1-slim-bookworm AS assets | ||
FROM ruby:3.4.1-slim-bullseye AS assets | ||
LABEL maintainer="Nick Janetakis <[email protected]>" | ||
|
||
WORKDIR /app | ||
|
||
# Define arguments at the start | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
RUN bash -c "set -o pipefail && apt-get update \ | ||
&& apt-get install -y --no-install-recommends build-essential curl git libpq-dev libyaml-dev \ | ||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /etc/apt/keyrings/nodesource.asc \ | ||
&& echo 'deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_22.x nodistro main' | tee /etc/apt/sources.list.d/nodesource.list \ | ||
&& apt-get update && apt-get install -y --no-install-recommends nodejs \ | ||
&& corepack enable \ | ||
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ | ||
&& apt-get clean \ | ||
&& groupadd -g \"${GID}\" ruby \ | ||
&& useradd --create-home --no-log-init -u \"${UID}\" -g \"${GID}\" ruby \ | ||
&& mkdir /node_modules && chown ruby:ruby -R /node_modules /app" | ||
# Create user first, before any package installations | ||
RUN groupadd -g ${GID} ruby && \ | ||
useradd --create-home --no-log-init -u ${UID} -g ${GID} ruby && \ | ||
mkdir -p /node_modules && \ | ||
chown ruby:ruby -R /node_modules /app | ||
|
||
# Install dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
libpq-dev \ | ||
libyaml-dev && \ | ||
mkdir -p /etc/apt/keyrings && \ | ||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /etc/apt/keyrings/nodesource.asc && \ | ||
echo 'deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_22.x nodistro main' | tee /etc/apt/sources.list.d/nodesource.list && \ | ||
apt-get update && \ | ||
apt-get install -y --no-install-recommends nodejs && \ | ||
corepack enable && \ | ||
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man && \ | ||
apt-get clean | ||
|
||
USER ruby | ||
|
||
|
@@ -36,27 +48,34 @@ ENV RAILS_ENV="${RAILS_ENV}" \ | |
COPY --chown=ruby:ruby . . | ||
|
||
RUN if [ "${RAILS_ENV}" != "development" ]; then \ | ||
SECRET_KEY_BASE_DUMMY=1 rails assets:precompile; fi | ||
SECRET_KEY_BASE_DUMMY=1 rails assets:precompile; \ | ||
fi | ||
|
||
CMD ["bash"] | ||
|
||
############################################################################### | ||
|
||
FROM ruby:3.4.1-slim-bookworm AS app | ||
FROM ruby:3.4.1-slim-bullseye AS app | ||
LABEL maintainer="Nick Janetakis <[email protected]>" | ||
|
||
WORKDIR /app | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends build-essential curl libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ | ||
&& apt-get clean \ | ||
&& groupadd -g "${GID}" ruby \ | ||
&& useradd --create-home --no-log-init -u "${UID}" -g "${GID}" ruby \ | ||
&& chown ruby:ruby -R /app | ||
# Create user first | ||
RUN groupadd -g ${GID} ruby && \ | ||
useradd --create-home --no-log-init -u ${UID} -g ${GID} ruby && \ | ||
chown ruby:ruby -R /app | ||
|
||
# Install dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
curl \ | ||
libpq-dev && \ | ||
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man && \ | ||
apt-get clean | ||
|
||
USER ruby | ||
|
||
|
@@ -76,4 +95,4 @@ ENTRYPOINT ["/app/bin/docker-entrypoint-web"] | |
|
||
EXPOSE 8000 | ||
|
||
CMD ["rails", "s"] | ||
CMD ["rails", "s"] |