From 4ea7b5886a1874c49c51a89e5b22013aced66465 Mon Sep 17 00:00:00 2001 From: James Hu Date: Sat, 16 Nov 2024 09:36:26 -0800 Subject: [PATCH] Refactor Dockerfile some more --- .dockerignore | 3 +-- CHANGELOG.md | 9 +++++++++ Dockerfile | 12 ++++++------ Gemfile.lock | 8 ++++---- docker-compose.yml | 4 +--- 5 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.dockerignore b/.dockerignore index d074c64..f6c66cc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -# .dockerignore .github/ .idea/ examples/ @@ -7,4 +6,4 @@ LICENSE .git/ *.md *.yml -Dockerfile \ No newline at end of file +Dockerfile diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3055e8e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [2.0.0] - 2024-11-16 +### Changed +- Refactored Docker image size to be smaller diff --git a/Dockerfile b/Dockerfile index 4549911..f8bca79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # The first stage is dedicated to building the application -FROM ruby:3.2.2-alpine as BUILD +FROM ruby:3.2.2-alpine AS build ENV PORT=9594 \ USER=app \ @@ -8,7 +8,7 @@ ENV PORT=9594 \ WORKDIR $ROOT -# Updating system packages and installing dependencies +# Update system packages and installing dependencies RUN apk update && apk upgrade && \ apk add --update --no-cache --virtual .build-deps \ build-base \ @@ -29,10 +29,10 @@ RUN gem install bundler && \ COPY . $ROOT/ # The second stage is responsible for preparing the runtime -FROM ruby:3.2.2-alpine as RUNTIME +FROM ruby:3.2.2-alpine AS runtime -# Copy over files from the BUILD step -COPY --from=BUILD $ROOT $ROOT +# Copy over files from the build step +COPY --from=build $ROOT $ROOT # Set environmental variables ENV PORT=9594 \ @@ -49,4 +49,4 @@ RUN addgroup -S $GROUP && \ USER $USER:$GROUP -CMD bundle exec puma -b tcp://0.0.0.0:$PORT \ No newline at end of file +CMD bundle exec puma -b tcp://0.0.0.0:$PORT diff --git a/Gemfile.lock b/Gemfile.lock index f0c111e..d4a5776 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,10 +34,10 @@ PLATFORMS x64-mingw-ucrt DEPENDENCIES - http - prometheus-client - puma - rack + http (~> 5.1.1) + prometheus-client (~> 4.2.2) + puma (~> 6.4.0) + rack (~> 3.0.8) RUBY VERSION ruby 3.2.2p53 diff --git a/docker-compose.yml b/docker-compose.yml index 267c3f3..15d6498 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ -version: '3.4' - services: app: - image: axsuul/plex-media-server-exporter:2022-11-26 + image: axsuul/plex-media-server-exporter build: . environment: # Can be set in .env