-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Optimise Docker file with new entrypoint
- Loading branch information
1 parent
689e6f2
commit e00e8e6
Showing
3 changed files
with
41 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2023 Kaushlendra Pratap <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Kaushlendra Pratap <[email protected]> | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
FROM golang:1.20 AS build | ||
|
||
|
@@ -12,19 +12,24 @@ COPY pkg/ pkg/ | |
COPY docs/ docs/ | ||
|
||
RUN wget https://raw.githubusercontent.com/fossology/fossology/master/install/db/licenseRef.json -O licenseRef.json | ||
RUN printf "TOKEN_HOUR_LIFESPAN=24\nAPI_SECRET=%s\n" $(openssl rand -hex 32) >> .env | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o laas ./cmd/laas | ||
|
||
# Release Stage | ||
FROM gcr.io/distroless/static-debian11 AS build-release | ||
FROM alpine:3.20 AS build-release | ||
|
||
WORKDIR / | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
COPY --from=build /LicenseDb/licenseRef.json /licenseRef.json | ||
RUN apk add --no-cache openssl bash \ | ||
&& chmod +x /entrypoint.sh | ||
|
||
WORKDIR /data | ||
|
||
COPY --from=build /LicenseDb/licenseRef.json /data/licenseRef.json | ||
COPY --from=build /LicenseDb/laas /laas | ||
COPY --from=build /LicenseDb/.env /.env | ||
|
||
EXPOSE 8080 | ||
|
||
CMD [ "./laas" ] | ||
USER noroot:noroot | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
# SPDX-FileCopyrightText: 2023 Kaushlendra Pratap <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Kaushlendra Pratap <[email protected]> | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
services: | ||
licensedb: | ||
container_name: licensedb | ||
build: | ||
context: . | ||
command: | ||
- "./laas" | ||
- "-host=postgres" | ||
- "-port=5432" | ||
- "-user=fossy" | ||
- "-dbname=fossology" | ||
- "-password=fossy" | ||
- "-datafile=licenseRef.json" | ||
- "-populatedb=true" | ||
environment: | ||
DB_PASSWORD: fossy | ||
DB_HOST: postgres | ||
DB_PORT: 5432 | ||
DB_USER: fossy | ||
DB_NAME: fossology | ||
POPULATE_DB: true | ||
GIN_MODE: debug | ||
ports: | ||
- "8080:8080" | ||
- 8080:8080 | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
volumes: | ||
- ./data:/data | ||
restart: always | ||
networks: | ||
- licensedb-network | ||
postgres: | ||
container_name: postgres | ||
image: postgres:14 | ||
image: postgres:16 | ||
environment: | ||
POSTGRES_PASSWORD: fossy | ||
POSTGRES_USER: fossy | ||
|
@@ -48,4 +45,3 @@ networks: | |
driver: bridge | ||
volumes: | ||
pgdata: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# SPDX-FileCopyrightText: 2024 Kaushlendra Pratap <[email protected]> | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
|
||
set -e | ||
|
||
db_host="${DB_HOST:-localhost}" | ||
db_port="${DB_PORT:-5432}" | ||
db_name="${DB_NAME:-fossology}" | ||
db_user="${DB_USER:-fossy}" | ||
db_password="${DB_PASSWORD:-fossy}" | ||
populate_db="${POPULATE_DB:-true}" | ||
data_file="/data/licenseRef.json" | ||
|
||
printf "TOKEN_HOUR_LIFESPAN=24\nAPI_SECRET=%s\n" $(openssl rand -hex 32) > .env | ||
|
||
/laas -host=$db_host -port=$db_port -user=$db_user -dbname=$db_name \ | ||
-password=$db_password -datafile="$data_file" -populatedb=$populate_db |