Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Dockerfile #626

Merged
merged 15 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.github
.idea
LICENSE
README.ms
docs
target/**
target/
!target/fdp-spring-boot.jar
!target/classes/application-production.yml
nb-configuration.xml
10 changes: 7 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: Publish to Docker Hub

on:
push:
branches:
- develop
pull_request:
release:
types: [created]
types:
- created

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -20,5 +24,5 @@ jobs:
uses: FAIRDataTeam/github-workflows/.github/workflows/docker-publish.yml@v2
secrets: inherit
with:
file: './Dockerfile.build'
push: ${{ github.event_name == 'release' && github.event.action == 'created' }}
file: './Dockerfile'
push: ${{ github.event_name == 'push' || github.event_name == 'release' }}
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Docker build
run: |
docker pull $PUBLIC_IMAGE:$TAG_DEVELOP
docker build --cache-from $PUBLIC_IMAGE:$TAG_DEVELOP -t fdp:snyk-test -f Dockerfile.build .
docker build --cache-from $PUBLIC_IMAGE:$TAG_DEVELOP -t fdp:snyk-test -f Dockerfile .

- name: Perform Snyk Check (Docker)
uses: snyk/actions/docker@master
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- Switched to Java 21 (LTS)
- Update to Java 21 by @MarekSuchanek in #471
- ??? (TODO)
- Get FAIR Data Team dependencies from Maven Central repository by @dennisvang in #577
- Fix issue templates by @dennisvang in #582
- Update CORS configuration by @dennisvang in #578
- Separate and reuse github workflows by @dennisvang in #617
- Prevent duplicate workflow runs by @dennisvang in #628
- Clean up Dockerfile by @dennisvang in #626

## [1.17.2]

### Fixed

- Fix metadata schemas (defaults, ordering, FDP shape)
- Default license in metadata schemas and configuration

## [1.17.1]

Expand Down Expand Up @@ -381,3 +394,4 @@ The first release of reference FAIR Data Point implementation.
[1.16.2]: /../../tree/v1.16.2
[1.17.0]: /../../tree/v1.17.0
[1.17.1]: /../../tree/v1.17.1
[1.17.2]: /../../tree/v1.17.2
49 changes: 24 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
#
# The MIT License
# Copyright © 2016-2024 FAIR Data Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# https://docs.docker.com/reference/dockerfile/#syntax
# syntax=docker/dockerfile:1

################################################################################
# BUILD JAR

FROM maven:3-eclipse-temurin-21-alpine AS builder

WORKDIR /builder

ADD . /builder

# https://maven.apache.org/ref/current/maven-embedder/cli.html
RUN mvn --quiet --batch-mode --update-snapshots --fail-fast -DskipTests package

################################################################################
# BUILD IMAGE

FROM eclipse-temurin:21-jdk-alpine

# add non-root user to run the app
# https://spring.io/guides/gs/spring-boot-docker
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring

WORKDIR /fdp

ADD target/fdp-spring-boot.jar /fdp/app.jar
ADD target/classes/application-production.yml /fdp/application.yml
COPY --from=builder /builder/target/fdp-spring-boot.jar /fdp/app.jar

ENTRYPOINT java -jar app.jar --spring.profiles.active=production --spring.config.location=classpath:/application.yml,classpath:/application-production.yml,file:/fdp/application.yml
ENTRYPOINT ["java", "-jar", "app.jar"]
42 changes: 0 additions & 42 deletions Dockerfile.build

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ If you do not have Java and Maven locally, you can build the Docker image using
built `jar` file):

```bash
$ docker build -f Dockerfile.build -t fairdatapoint:local .
$ docker build -f Dockerfile -t fairdatapoint:local .
```

## Security
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
<exclude>**/*.json</exclude>
<exclude>LICENSE</exclude>
<exclude>.dockerignore</exclude>
<exclude>Dockerfile.build</exclude>
<exclude>Dockerfile</exclude>
</excludes>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Repository mainRepository(ApplicationContext context) throws RepositoryEx

@Bean(initMethod = "init", destroyMethod = "shutDown", name = "draftsRepository")
public Repository draftsRepository(ApplicationContext context) throws RepositoryException {
return prepareRepository(context, repositoryProperties.getMain());
return prepareRepository(context, repositoryProperties.getDrafts());
}

public Repository prepareRepository(ApplicationContext context, RepositoryConnectionProperties properties)
Expand Down
Loading