Skip to content

Commit

Permalink
Format Dockerfile and clean up temporary files
Browse files Browse the repository at this point in the history
Reformatted RUN commands in the Dockerfile for improved readability and consistency by chaining them with backslashes. Added commands to remove temporary files after use, enhancing cleanliness and reducing image size.
  • Loading branch information
meanmail committed Sep 18, 2024
1 parent cfbf42b commit b65bfcf
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,50 @@ ENV PMD_DIRECTORY ${LINTERS_DIRECTORY}/pmd
ENV GOLANG_LINT_VERSION 1.49.0

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV GOLANG_LINT_DIRECTORY ${LINTERS_DIRECTORY}/golangci-lint

Check warning on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Image

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

RUN mkdir -p ${CHECKSTYLE_DIRECTORY} && \
mkdir -p ${DETEKT_DIRECTORY} && \
mkdir -p ${PMD_DIRECTORY} && \
mkdir -p ${GOLANG_LINT_DIRECTORY}
RUN mkdir -p ${CHECKSTYLE_DIRECTORY} \
&& mkdir -p ${DETEKT_DIRECTORY} \
&& mkdir -p ${PMD_DIRECTORY} \
&& mkdir -p ${GOLANG_LINT_DIRECTORY}

# Install Curl and Unzip
RUN apt -y update && \
apt -y upgrade && \
apt -y install curl unzip
RUN apt -y update \
&& apt -y upgrade \
&& apt -y install curl unzip \
&& rm -rf /var/lib/apt/lists/*

# Install eslint
RUN npm install eslint@${ESLINT_VERSION} -g && \
eslint --init
RUN npm install eslint@${ESLINT_VERSION} -g \
&& eslint --init

# Install Detekt and Detekt-formatting
RUN curl -sSLO https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/detekt-cli-${DETEKT_VERSION}.zip && \
unzip detekt-cli-${DETEKT_VERSION}.zip -d ${DETEKT_DIRECTORY} && \
curl -H "Accept: application/zip" https://repo.maven.apache.org/maven2/io/gitlab/arturbosch/detekt/detekt-formatting/${DETEKT_VERSION}/detekt-formatting-${DETEKT_VERSION}.jar -o ${DETEKT_DIRECTORY}/detekt-formatting-${DETEKT_VERSION}.jar
RUN curl -sSLO https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/detekt-cli-${DETEKT_VERSION}.zip \
&& unzip detekt-cli-${DETEKT_VERSION}.zip -d ${DETEKT_DIRECTORY} \
&& rm detekt-cli-${DETEKT_VERSION}.zip \
&& curl -H "Accept: application/zip" https://repo.maven.apache.org/maven2/io/gitlab/arturbosch/detekt/detekt-formatting/${DETEKT_VERSION}/detekt-formatting-${DETEKT_VERSION}.jar -o ${DETEKT_DIRECTORY}/detekt-formatting-${DETEKT_VERSION}.jar

# Install Checkstyle
RUN curl -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${CHECKSTYLE_VERSION}/checkstyle-${CHECKSTYLE_VERSION}-all.jar > ${CHECKSTYLE_DIRECTORY}/checkstyle-${CHECKSTYLE_VERSION}-all.jar

# Install PMD
RUN curl -sSLO https://github.com/pmd/pmd/releases/download/pmd_releases/${PMD_VERSION}/pmd-bin-${PMD_VERSION}.zip && \
unzip pmd-bin-${PMD_VERSION}.zip -d ${PMD_DIRECTORY}
RUN curl -sSLO https://github.com/pmd/pmd/releases/download/pmd_releases/${PMD_VERSION}/pmd-bin-${PMD_VERSION}.zip \
&& unzip pmd-bin-${PMD_VERSION}.zip -d ${PMD_DIRECTORY} \
&& rm pmd-bin-${PMD_VERSION}.zip

# Install golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b ${GOLANG_LINT_DIRECTORY} v${GOLANG_LINT_VERSION}
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b ${GOLANG_LINT_DIRECTORY} v${GOLANG_LINT_VERSION}

# Install third party golang libraries and pre-cache them by compiling main.go
# Taken from: https://github.com/StepicOrg/epicbox-images/blob/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/Dockerfile
RUN curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/go.mod && \
curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/go.sum && \
curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/main.go && \
go mod download && \
go mod verify && \
go mod tidy && \
go run main.go && \
rm main.go && \
chmod ugo-w go.mod go.sum
RUN curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/go.mod \
&& curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/go.sum \
&& curl -sSfLO https://raw.githubusercontent.com/StepicOrg/epicbox-images/a5eadb5211909fc7ef99724ee0b8bf3a758ae1b7/epicbox-go/main.go \
&& go mod download \
&& go mod verify \
&& go mod tidy \
&& go run main.go \
&& rm main.go \
&& chmod ugo-w go.mod go.sum

ARG POETRY_VERSION=1.8.3
RUN pip install poetry==${POETRY_VERSION}
Expand Down

0 comments on commit b65bfcf

Please sign in to comment.