Skip to content

Commit

Permalink
✨ Remove redis (#198)
Browse files Browse the repository at this point in the history
* ✨ Remove redis

* ✨ Cache support ttl
  • Loading branch information
tosone authored Oct 7, 2023
1 parent 4aea32c commit 3026984
Show file tree
Hide file tree
Showing 38 changed files with 433 additions and 2,731 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
with:
context: .
file: build/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
with:
context: .
file: build/Dockerfile.debian
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
with:
context: .
file: build/Dockerfile.builder
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
7 changes: 0 additions & 7 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,10 @@ RUN make build

FROM alpine:${ALPINE_VERSION}

RUN set -eux && \
apk add --no-cache redis yq

COPY --from=syft /usr/local/bin/syft /usr/local/bin/syft
COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=trivy /opt/trivy/trivy.db /opt/trivy/db/trivy.db
COPY ./conf/config.yaml /etc/sigma/config.yaml
COPY ./build/entrypoint.sh /entrypoint.sh
COPY ./conf/redis.conf /etc/sigma/redis.conf
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma /usr/local/bin/sigma

ENTRYPOINT ["/entrypoint.sh"]

CMD ["sigma", "server"]
12 changes: 0 additions & 12 deletions build/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,22 @@ RUN make build
FROM debian:${DEBIAN_VERSION}

ARG TARGETARCH=amd64
ARG YQ_VERSION=v4.34.2

RUN set -eux && \
apt-get update && \
apt-get install -y --no-install-recommends \
redis \
wget \
ca-certificates \
curl \
netbase \
gnupg \
dirmngr \
&& \
case "${TARGETARCH}" in \
amd64) export YQ_ARCH='amd64' ;; \
arm64) export YQ_ARCH='arm64' ;; \
esac; \
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${YQ_ARCH}.tar.gz -O - | tar xz && mv yq_linux_${YQ_ARCH} /usr/bin/yq && \
rm -rf /var/lib/apt/lists/*

COPY --from=syft /usr/local/bin/syft /usr/local/bin/syft
COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=trivy /opt/trivy/trivy.db /opt/trivy/db/trivy.db
COPY ./conf/config.yaml /etc/sigma/config.yaml
COPY ./build/entrypoint.sh /entrypoint.sh
COPY ./conf/redis.conf /etc/sigma/redis.conf
COPY --from=builder /go/src/github.com/go-sigma/sigma/bin/sigma /usr/local/bin/sigma

ENTRYPOINT ["/entrypoint.sh"]

CMD ["sigma", "server"]
13 changes: 0 additions & 13 deletions build/entrypoint.sh

This file was deleted.

11 changes: 5 additions & 6 deletions cmd/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/go-sigma/sigma/pkg/cmds/distribution"
"github.com/go-sigma/sigma/pkg/configs"
"github.com/go-sigma/sigma/pkg/daemon"
"github.com/go-sigma/sigma/pkg/dal"
"github.com/go-sigma/sigma/pkg/inits"
"github.com/go-sigma/sigma/pkg/logger"
Expand Down Expand Up @@ -55,11 +54,11 @@ var distributionCmd = &cobra.Command{
return
}

err = daemon.InitializeClient()
if err != nil {
log.Error().Err(err).Msg("Initialize daemon client with error")
return
}
// err = daemon.InitializeClient()
// if err != nil {
// log.Error().Err(err).Msg("Initialize daemon client with error")
// return
// }

err = distribution.Serve()
if err != nil {
Expand Down
21 changes: 4 additions & 17 deletions pkg/configs/deploy.go → cmd/imports/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package configs
package imports

import (
"fmt"

"github.com/spf13/viper"
_ "github.com/distribution/distribution/v3/manifest/manifestlist"
_ "github.com/distribution/distribution/v3/manifest/ocischema"
_ "github.com/distribution/distribution/v3/manifest/schema2"
)

func init() {
checkers = append(checkers, checkDeploy)
}

func checkDeploy() error {
if viper.GetString("deploy") == "replica" {
if viper.GetString("redis.type") == "internal" {
return fmt.Errorf("Deploy replica should use external redis")
}
}
return nil
}
11 changes: 5 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/go-sigma/sigma/pkg/cmds/server"
"github.com/go-sigma/sigma/pkg/configs"
"github.com/go-sigma/sigma/pkg/daemon"
"github.com/go-sigma/sigma/pkg/dal"
"github.com/go-sigma/sigma/pkg/inits"
"github.com/go-sigma/sigma/pkg/logger"
Expand Down Expand Up @@ -54,11 +53,11 @@ var serverCmd = &cobra.Command{
return
}

err = daemon.InitializeClient()
if err != nil {
log.Error().Err(err).Msg("Initialize daemon client with error")
return
}
// err = daemon.InitializeClient()
// if err != nil {
// log.Error().Err(err).Msg("Initialize daemon client with error")
// return
// }

err = server.Serve(server.ServerConfig{
WithoutDistribution: withoutDistribution,
Expand Down
4 changes: 2 additions & 2 deletions conf/config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ database:
deploy: single

redis:
# redis type available: internal, external
type: internal
# redis type available: none, external
type: none
url: redis://:sigma@localhost:6379/0

cache:
Expand Down
4 changes: 2 additions & 2 deletions conf/config-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ database:
deploy: single

redis:
# redis type available: internal, external
type: internal
# redis type available: none, external
type: none
url: redis://:sigma@localhost:6379/0

cache:
Expand Down
6 changes: 3 additions & 3 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ database:
deploy: single

redis:
# redis type available: internal, external
type: internal
# redis type available: none, external
type: none
url: redis://:sigma@localhost:6379/0

cache:
# the cache type available is: redis, inmemory, database
type: redis
type: database
# please attention in multi
inmemory:
size: 10240
Expand Down
Loading

0 comments on commit 3026984

Please sign in to comment.