Skip to content

Commit

Permalink
Merge pull request #759 from momocus/pr/add-docker-check
Browse files Browse the repository at this point in the history
  • Loading branch information
momocus authored Nov 28, 2024
2 parents 488c565 + a0b9979 commit 25c74f0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ jobs:
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: fly.Dockerfile

# lint by docker build checks
- name: Run Docker Build Checks for dev.Dockerfile
run: docker build --check --file dev.Dockerfile .
- name: Run Docker Build Checks for fly.Dockerfile
run: docker build --check --file fly.Dockerfile .
10 changes: 10 additions & 0 deletions cli-scripts/run-all-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ if [ -n "${HADOLINT}" ]; then
else
warning "[SKIP] Hadolint, hadolint or Docker is required."
fi

message "##### Run Docker Build Checks"
if type docker > /dev/null 2>&1; then
files=$(git ls-files | grep "Dockerfile")
for file in ${files}; do
docker build --check --file "${file}" .
done
else
warning "[SKIP] Docker Build Checks, Docker is required."
fi
28 changes: 14 additions & 14 deletions fly.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

ARG RUBY_VERSION
ARG VARIANT=jemalloc-bullseye-slim
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} AS base

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand All @@ -33,21 +33,21 @@ ARG BUNDLER_VERSION=2.5.16
ARG RAILS_ENV=production
ENV RAILS_ENV=${RAILS_ENV}

ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES=true
ENV RAILS_LOG_TO_STDOUT=true

ARG BUNDLE_WITHOUT=development:test
ARG BUNDLE_PATH=vendor/bundle
ENV BUNDLE_PATH ${BUNDLE_PATH}
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
ENV BUNDLE_PATH=${BUNDLE_PATH}
ENV BUNDLE_WITHOUT=${BUNDLE_WITHOUT}

RUN mkdir /app
WORKDIR /app
RUN mkdir -p tmp/pids

RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH
ENV VOLTA_HOME=/root/.volta
ENV PATH=$VOLTA_HOME/bin:/usr/local/bin:$PATH
RUN volta install node@${NODE_VERSION} yarn@${YARN_VERSION} && \
gem update --system --no-document && \
gem install -N bundler -v ${BUNDLER_VERSION}
Expand All @@ -56,10 +56,10 @@ RUN volta install node@${NODE_VERSION} yarn@${YARN_VERSION} && \

# install packages only needed at build time

FROM base as build_deps
FROM base AS build_deps

ARG BUILD_PACKAGES="build-essential=12.* libpq-dev=13.* libyaml-dev=0.2.*"
ENV BUILD_PACKAGES ${BUILD_PACKAGES}
ENV BUILD_PACKAGES=${BUILD_PACKAGES}

# hadolint ignore=DL3008
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
Expand All @@ -72,7 +72,7 @@ RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \

# install gems

FROM build_deps as gems
FROM build_deps AS gems

COPY Gemfile Gemfile.lock .ruby-version ./
RUN bundle install && \
Expand All @@ -82,7 +82,7 @@ RUN bundle install && \

# install node modules

FROM build_deps as node_modules
FROM build_deps AS node_modules

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/releases/ ./.yarn/releases/
Expand Down Expand Up @@ -126,7 +126,7 @@ RUN chmod +x /app/bin/* && \
# The following enable assets to precompile on the build server. Adjust
# as necessary. If no combination works for you, see:
# https://fly.io/docs/rails/getting-started/existing/#access-to-environment-variables-at-build-time
ENV SECRET_KEY_BASE 1
ENV SECRET_KEY_BASE=1
# ENV AWS_ACCESS_KEY_ID=1
# ENV AWS_SECRET_ACCESS_KEY=1

Expand All @@ -135,8 +135,8 @@ ARG BUILD_COMMAND="bin/rails fly:build"
RUN ${BUILD_COMMAND}

# Default server start instructions. Generally Overridden by fly.toml.
ENV PORT 8080
ENV PORT=8080
ARG SERVER_COMMAND="bin/rails fly:server"
ENV SERVER_COMMAND ${SERVER_COMMAND}
ENV SERVER_COMMAND=${SERVER_COMMAND}
# hadolint ignore=DL3025
CMD ${SERVER_COMMAND}

0 comments on commit 25c74f0

Please sign in to comment.