Skip to content

Commit

Permalink
moved docs creation to dockerfile from ci; optimized docker size and …
Browse files Browse the repository at this point in the history
…libraries; (#292)
  • Loading branch information
codacy-vrhpires authored May 10, 2024
1 parent 2812449 commit 236cb9d
Showing 5 changed files with 37 additions and 52 deletions.
19 changes: 6 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -7,27 +7,20 @@ orbs:
workflows:
compile_test_deploy:
jobs:
- codacy/checkout_and_version:
write_sbt_version: true
- codacy/sbt:
name: build_docs_and_docker
- codacy/checkout_and_version
- codacy/shell:
name: publish_docker_local
cmd: |
wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.3/phpDocumentor.phar
sudo mv phpDocumentor.phar /usr/local/bin/phpdoc
sudo chmod +x /usr/local/bin/phpdoc
sbt "runMain codacy.codesniffer.docsgen.GeneratorMain"
docker build -t $CIRCLE_PROJECT_REPONAME .
docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME
docker build -t $CIRCLE_PROJECT_REPONAME:latest .
docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest
persist_to_workspace: true
requires:
- codacy/checkout_and_version
- codacy_plugins_test/run:
name: plugins_test
run_multiple_tests: true
requires:
- build_docs_and_docker
- publish_docker_local
- codacy/publish_docker:
context: CodacyDocker
requires:
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project/*
!project/build.properties
!project/plugins.sbt
34 changes: 12 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
/RUNNING_PID
/logs/
/project/*-shim.sbt
/project/project/
/project/target/
/target/
.idea
.DS_Store

.vscode

.bsp
.bloop
.bsp
.DS_Store
.idea
.metals
*metals.sbt

vendor/

.phpdoc/
.phpcs-cache
.phpdoc
.vscode
RUNNING_PID
target
vendor

###> squizlabs/php_codesniffer ###
/.phpcs-cache
###< squizlabs/php_codesniffer ###
project/*
!project/build.properties
!project/plugins.sbt

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
31 changes: 15 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-11.0.22_7_1.9.9_2.13.13 as builder
WORKDIR /app
COPY build.sbt .
COPY docs /docs
COPY project project
COPY src src
COPY build.sbt .

RUN wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.3/phpDocumentor.phar && \
mv phpDocumentor.phar /usr/local/bin/phpdoc && \
chmod +x /usr/local/bin/phpdoc && \
sbt 'runMain codacy.codesniffer.docsgen.GeneratorMain'
RUN sbt stage

FROM php:8.2-alpine
@@ -15,32 +21,25 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PATH ${COMPOSER_HOME}/vendor/bin:${PATH}

# Install necessary packages
RUN apk --no-cache add git openssh-client openjdk11-jre-headless \
php82-openssl php82-phar php82-simplexml php82-json php82-curl \
php82-iconv php82-zlib php82-simplexml php82-tokenizer \
php82-xmlwriter php82-mbstring php82-xml php82-dom php82-xmlreader
RUN apk --no-cache add php82 openjdk11-jre-headless

# Configure PHP settings
RUN ln -s /etc/php82/php.ini /etc/php82/conf.d/php.ini && \
sed 's/.*short_open_tag.*=.*/short_open_tag=On/' /etc/php82/php.ini -i
RUN sed 's/.*short_open_tag.*=.*/short_open_tag=On/' /etc/php82/php.ini -i

# Install Composer
# Install Composer and packages
RUN curl -sS https://getcomposer.org/installer | php

# Install packages
COPY composer.* ${COMPOSER_HOME}
RUN php composer.phar global install

# Clean up temporary files and cache
# Cleanup and miscellaneous
RUN rm -rf /tmp/* && \
adduser -u 2004 -D docker

# Copy codacy-codesniffer binary and docs
COPY --chown=docker:docker --from=builder /app/target/universal/stage/bin /app/scala/bin
COPY --chown=docker:docker --from=builder /app/target/universal/stage/lib /app/scala/lib
COPY --chown=docker:docker docs /docs
# Copy codacy-codesniffer and docs
COPY --chown=docker:docker --from=builder /app/target/universal/stage scala
COPY --chown=docker:docker --from=builder /docs /docs

WORKDIR /src

USER docker
ENTRYPOINT ["/app/scala/bin/codacy-codesniffer"]
ENTRYPOINT ["/app/scala/bin/codacy-codesniffer"]
2 changes: 1 addition & 1 deletion src/main/scala/codacy/codesniffer/docsgen/Generator.scala
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ class Generator() {
private[this] val toolName = Tool.Name("phpcs")
private[this] val toolVersion = Option(Tool.Version(VersionsHelper.codesniffer))

val docsDir = File("docs")
val docsDir = File("/docs")
val patternsFile: File = docsDir / "patterns.json"
val descriptionsDir: File = docsDir / "description"
val descriptionFile: File = descriptionsDir / "description.json"

0 comments on commit 236cb9d

Please sign in to comment.