today_ai_weather/Dockerfile.build
songtianlun 378530cc1b feat: automate base image build for GitHub Actions
- Added new GitHub Actions to docker-main.yml to build and push base images
- Created a new Dockerfile.base with the base packages installation
- Modified the existing Dockerfile to use the new base image
- Created a new Dockerfile.build with the build stage to reduce the size of the final image
2025-02-02 00:38:11 +08:00

31 lines
1.0 KiB
Docker

ARG BASE_IMAGE=docker.io/your-username/today_ai_weather-base:main
FROM ${BASE_IMAGE} AS base
# Rails app lives here
WORKDIR /rails
# Install base packages, Move to Base Dockerfile.
# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
# Throw-away build stage to reduce size of final image
FROM base AS build
# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git node-gyp pkg-config python-is-python3 libpq-dev && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install JavaScript dependencies
ARG NODE_VERSION=20.17.0
ARG YARN_VERSION=1.22.22
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
npm install -g yarn@$YARN_VERSION && \
rm -rf /tmp/node-build-master