Skip to content

Commit

Permalink
Merge branch 'goreleaser' of https://github.com/bikeshack/smd into in…
Browse files Browse the repository at this point in the history
…sert-endpoint
  • Loading branch information
davidallendj committed Oct 11, 2023
2 parents 87c2b5a + 2853c46 commit aa52ee0
Show file tree
Hide file tree
Showing 1,008 changed files with 1,820 additions and 349,490 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
cmd/smd-loader/node_nid_map.json
kubernetes/cray-hms-smd/helm
.idea
smd
smd-init
smd-loader

# Prevent certificates from getting checked in
*.ca
Expand All @@ -16,3 +13,5 @@ smd-loader
*.csr
*.key
*.pem

dist/
103 changes: 103 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

project_name: smd
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: smd
main: ./cmd/smd/
binary: smd
goos:
- linux
goarch:
- amd64
- arm64
no_unique_dist_dir: true
tags:
- musl
- dynamic

- id: smd-init
main: ./cmd/smd-init/
binary: smd-init
goos:
- linux
goarch:
- amd64
- arm64
no_unique_dist_dir: true
tags:
- musl
- dynamic
- id: smd-loader
main: ./cmd/smd-loader/
binary: smd-loader
goos:
- linux
goarch:
- amd64
- arm64
no_unique_dist_dir: true
tags:
- musl
- dynamic

dockers:
-
image_templates:
- bikeshack/{{.ProjectName}}:latest
- bikeshack/{{.ProjectName}}:{{ .Tag }}
- bikeshack/{{.ProjectName}}:{{ .Major }}
- bikeshack/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- LICENSE
- CHANGELOG.md
- README.md
- migrations/*




archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
files:
- migrations/*
- LICENSE
- CHANGELOG.md
- README.md


checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'


# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
1 change: 0 additions & 1 deletion .version

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ 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.9.1]

### Fixed

- Linter Errors

### Changed

- Support local builds
- Support goreleaser for builds/releases
- Move to github.com/bikeshack/hms-smd
- Container now based on wolfi
- Deprecated built-in kafaka listener for redfish events

## [2.9.0] - 2023-05-19

### Fixed
Expand Down
118 changes: 10 additions & 108 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,118 +1,20 @@
# MIT License
#
# (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
#
# 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.
FROM cgr.dev/chainguard/wolfi-base

# Dockerfile for building HMS State Manager.
RUN apk add --no-cache tini


### Build Base Stage ###
# Build base just has the packages installed we need.
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
&& apk add build-base
COPY smd /
COPY smd-loader /
COPY smd-init /
RUN mkdir /persistent_migrations
COPY migrations/* /persistent_migrations/


### Base Stage ###
# Base copies in the files we need to test/build.
FROM build-base AS base

RUN go env -w GO111MODULE=auto

# Copy all the necessary files to the image.
COPY cmd $GOPATH/src/github.com/Cray-HPE/hms-smd/v2/cmd
COPY internal $GOPATH/src/github.com/Cray-HPE/hms-smd/v2/internal
COPY pkg $GOPATH/src/github.com/Cray-HPE/hms-smd/v2/pkg
COPY vendor $GOPATH/src/github.com/Cray-HPE/hms-smd/v2/vendor


### Build Stage ###
FROM base AS builder

# Base image contains everything needed for Go building, just build.
RUN set -ex \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd-loader \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd-init


### Final Stage ###
FROM artifactory.algol60.net/docker.io/alpine:3.15
LABEL maintainer="Hewlett Packard Enterprise"
EXPOSE 27779
STOPSIGNAL SIGTERM

# Copy the entrypoint and schema files.
COPY migrations/postgres /migrations
COPY entrypoint.sh /

ENV SMD_DBNAME="hmsds"
ENV SMD_DBUSER="hmsdsuser"
ENV SMD_DBTYPE="postgres"
ENV SMD_DBPORT=5432
ENV SMD_DBOPTS="sslmode=disable"

# yaml should always overwrite password using kubernetes secrets in production.
ENV SMD_DBHOST="cray-smd-postgres"
ENV SMD_DBPASS="hmsdsuser"

ENV TLSCERT=""
ENV TLSKEY=""

ENV VAULT_ADDR="http://cray-vault.vault:8200"
ENV VAULT_SKIP_VERIFY="true"

ENV SMD_RVAULT="true"
ENV SMD_WVAULT="true"

ENV RF_MSG_HOST "cray-shared-kafka-kafka-bootstrap.services.svc.cluster.local:9092:cray-dmtf-resource-event"
ENV LOGLEVEL 2

ENV SMD_SLS_HOST "http://cray-sls/v1"

ENV SMD_HBTD_HOST "http://cray-hbtd/hmi/v1"

ENV SMD_HWINVHIST_AGE_MAX_DAYS=365

ENV HMS_CONFIG_PATH="/hms_config/hms_config.json"

ENV SMD_CA_URI=""

# Copy the final binary
COPY --from=builder /go/smd /usr/local/bin
COPY --from=builder /go/smd-loader /usr/local/bin
COPY --from=builder /go/smd-init /usr/local/bin

COPY configs /configs

# Cannot live without these packages installed.
RUN set -ex \
&& apk -U upgrade \
&& apk add --no-cache \
postgresql-client \
&& mkdir -p /persistent_migrations \
&& chmod 777 /persistent_migrations

# nobody 65534:65534
USER 65534:65534

CMD ["sh", "-c", "smd -db-dsn=$DBDSN -tls-cert=$TLSCERT -tls-key=$TLSKEY -log=$LOGLEVEL -dbhost=$POSTGRES_HOST -dbport=$POSTGRES_PORT -sls-url=$SMD_SLS_HOST"]
CMD [ "/smd" ]

ENTRYPOINT [ "/sbin/tini", "--" ]
118 changes: 118 additions & 0 deletions Dockerfile.CSM
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# MIT License
#
# (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
#
# 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.

# Dockerfile for building HMS State Manager.


### Build Base Stage ###
# Build base just has the packages installed we need.
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
&& apk add build-base


### Base Stage ###
# Base copies in the files we need to test/build.
FROM build-base AS base

RUN go env -w GO111MODULE=auto

# Copy all the necessary files to the image.
COPY cmd $GOPATH/src/github.com/bikeshack/hms-smd/v2/cmd
COPY internal $GOPATH/src/github.com/bikeshack/hms-smd/v2/internal
COPY pkg $GOPATH/src/github.com/bikeshack/hms-smd/v2/pkg
COPY vendor $GOPATH/src/github.com/bikeshack/hms-smd/v2/vendor


### Build Stage ###
FROM base AS builder

# Base image contains everything needed for Go building, just build.
RUN set -ex \
&& go build -v -tags musl -i github.com/bikeshack/hms-smd/v2/cmd/smd \
&& go build -v -tags musl -i github.com/bikeshack/hms-smd/v2/cmd/smd-loader \
&& go build -v -tags musl -i github.com/bikeshack/hms-smd/v2/cmd/smd-init


### Final Stage ###
FROM artifactory.algol60.net/docker.io/alpine:3.15
LABEL maintainer="Hewlett Packard Enterprise"
EXPOSE 27779
STOPSIGNAL SIGTERM

# Copy the entrypoint and schema files.
COPY migrations/postgres /migrations
COPY entrypoint.sh /

ENV SMD_DBNAME="hmsds"
ENV SMD_DBUSER="hmsdsuser"
ENV SMD_DBTYPE="postgres"
ENV SMD_DBPORT=5432
ENV SMD_DBOPTS="sslmode=disable"

# yaml should always overwrite password using kubernetes secrets in production.
ENV SMD_DBHOST="cray-smd-postgres"
ENV SMD_DBPASS="hmsdsuser"

ENV TLSCERT=""
ENV TLSKEY=""

ENV VAULT_ADDR="http://cray-vault.vault:8200"
ENV VAULT_SKIP_VERIFY="true"

ENV SMD_RVAULT="true"
ENV SMD_WVAULT="true"

ENV RF_MSG_HOST "cray-shared-kafka-kafka-bootstrap.services.svc.cluster.local:9092:cray-dmtf-resource-event"
ENV LOGLEVEL 2

ENV SMD_SLS_HOST "http://cray-sls/v1"

ENV SMD_HBTD_HOST "http://cray-hbtd/hmi/v1"

ENV SMD_HWINVHIST_AGE_MAX_DAYS=365

ENV HMS_CONFIG_PATH="/hms_config/hms_config.json"

ENV SMD_CA_URI=""

# Copy the final binary
COPY --from=builder /go/smd /usr/local/bin
COPY --from=builder /go/smd-loader /usr/local/bin
COPY --from=builder /go/smd-init /usr/local/bin

COPY configs /configs

# Cannot live without these packages installed.
RUN set -ex \
&& apk -U upgrade \
&& apk add --no-cache \
postgresql-client \
&& mkdir -p /persistent_migrations \
&& chmod 777 /persistent_migrations

# nobody 65534:65534
USER 65534:65534

CMD ["sh", "-c", "smd -db-dsn=$DBDSN -tls-cert=$TLSCERT -tls-key=$TLSKEY -log=$LOGLEVEL -dbhost=$POSTGRES_HOST -dbport=$POSTGRES_PORT -sls-url=$SMD_SLS_HOST"]
Loading

0 comments on commit aa52ee0

Please sign in to comment.