Skip to content

Commit

Permalink
Merge pull request #341 from jmpsec/dev-env
Browse files Browse the repository at this point in the history
Dev env
  • Loading branch information
javuto authored Jan 20, 2024
2 parents a680c52 + 47aa3c9 commit 94e0afb
Show file tree
Hide file tree
Showing 43 changed files with 857 additions and 780 deletions.
25 changes: 8 additions & 17 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
*
!.env
!admin/static
!admin/templates
!deploy/osquery/data
!docker/
!osctrl-tls-*.bin
!osctrl-api-*.bin
!osctrl-admin-*.bin
!osctrl-cli-*.bin
!deploy/docker/conf/osquery/wait-cli.sh
!deploy/docker/conf/osctrl/cli/db.json
!deploy/docker/conf/osctrl/cli/entrypoint.sh
!deploy/docker/conf/tls/*
!deploy/docker/conf/osquery/entrypoint.sh
!deploy/docker/conf/osctrl/db.json
!deploy/docker/conf/nginx/*.conf
*.md
LICENSE
Vagrantfile
*.png
tmp/
bin/
docker-compose.yml
docker-compose-dev.yml
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ REDIS_VERSION=6.2.6-alpine3.15
JWT_SECRET=0000000000000000000000000000000000000000000000000000000000000000
OSCTRL_USER=admin
OSCTRL_PASS=Changeme123!
GOLANG_VERSION=1.21.3
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ osctrl-api.json
# Go Workspace
go.work
go.work.sum

deploy/docker/conf/tls/*
.env
!deploy/docker/conf/tls/openssl.cnf.example
Binary file added .img/docker_openssl_generate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .img/docker_uuid_gen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 37 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,40 @@ logs_tls:
sudo journalctl -f -t $(TLS_NAME)

# Display docker logs for TLS server
docker_logs_tls:
docker logs -f $(TLS_NAME)
docker_dev_logs_tls:
docker logs -f $(TLS_NAME)-dev

# Display systemd logs for Admin server
logs_admin:
sudo journalctl -f -t $(ADMIN_NAME)

# Display docker logs for Admin server
docker_logs_admin:
docker logs -f $(ADMIN_NAME)
docker_dev_logs_admin:
docker logs -f $(ADMIN_NAME)-dev

# Display systemd logs for API server
logs_api:
sudo journalctl -f -t $(API_NAME)

# Display docker logs for API server
docker_logs_api:
docker logs -f $(API_NAME)
docker_dev_logs_api:
docker logs -f $(API_NAME)-dev

# Display docker logs for nginx server
docker_dev_logs_nginx:
docker logs -f osctrl-nginx-dev

# Display docker logs for osquery client
docker_dev_logs_osquery:
docker logs -f osctrl-osquery-dev

# Display docker logs for postgresql server
docker_dev_logs_postgresql:
docker logs -f osctrl-postgres-dev

# Display docker logs for redis server
docker_dev_logs_redis:
docker logs -f osctrl-redis-dev

# Destroy existing vagrant development VM
vagrant_destroy:
Expand All @@ -161,34 +177,26 @@ vagrant_up:
mkcert -key-file "certs/osctrl-admin.key" -cert-file "certs/osctrl-admin.crt" "osctrl.dev"
vagrant up

# Build prod docker containers and run them (also generates new certificates)
docker_prod:
./deploy/docker/dockerize.sh -u -b -f -J

# Build dev docker containers and run them (also generates new certificates)
docker_dev:
./deploy/docker/dockerize.sh -u -b -f -J -D
docker_dev_build:
ifeq (,$(wildcard .env))
$(error Missing .env file)
endif
ifeq (,$(wildcard ./deploy/docker/conf/tls/osctrl.crt))
$(error Missing TLS certificate file)
endif
ifeq (,$(wildcard ./deploy/docker/conf/tls/osctrl.key))
$(error Missing TLS private key file)
endif
docker-compose -f docker-compose-dev.yml build

# Run docker containers
docker_up:
./deploy/docker/dockerize.sh -u

# Build docker containers
docker_build:
./deploy/docker/dockerize.sh -b
docker_dev_up:
docker-compose -f docker-compose-dev.yml up

# Takes down docker containers
docker_down:
./deploy/docker/dockerize.sh -d

# Cleans docker containers and certificates
docker_clean:
make docker_down
./deploy/docker/dockerize.sh -x
rm -Rf deploy/docker/conf/tls/*.crt
rm -Rf deploy/docker/conf/tls/*.key
rm -Rf .env
docker volume rm osctrl-postgres-db
docker_dev_down:
docker-compose -f docker-compose-dev.yml down

# Auto-format and simplify the code
GOFMT_ARGS = -l -w -s
Expand Down
2 changes: 1 addition & 1 deletion deploy/cicd/docker/Dockerfile-osctrl-admin
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ARG GOARCH=amd64

# Install software
RUN apt-get update -y -q && \
apt-get install curl -y && \
rm -rf /var/lib/apt/lists/*

# Install/Setup osctrl
RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin && \
mkdir -p /opt/osctrl/config && \
mkdir -p /opt/osctrl/script && \
mkdir -p /opt/osctrl/tmpl_admin/components && \
mkdir -p /opt/osctrl/static && \
mkdir -p /opt/osctrl/data && \
Expand Down
2 changes: 1 addition & 1 deletion deploy/cicd/docker/Dockerfile-osctrl-api
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ARG GOARCH=amd64

# Install software
RUN apt-get update -y -q && \
apt-get install curl -y && \
rm -rf /var/lib/apt/lists/*

# Install/Setup osctrl
RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin && \
mkdir -p /opt/osctrl/config && \
mkdir -p /opt/osctrl/script && \
chown osctrl-${COMPONENT}:osctrl-${COMPONENT} -R /opt/osctrl
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
RUN chmod 755 /opt/osctrl/bin/osctrl-${COMPONENT}
Expand Down
5 changes: 2 additions & 3 deletions deploy/cicd/docker/Dockerfile-osctrl-cli
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ ARG GOARCH=amd64

# Install software
RUN apt-get update -y -q && \
apt-get install curl -y && \
rm -rf /var/lib/apt/lists/*

# Install/Setup osctrl
RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin && \
mkdir -p /opt/osctrl/config && \
mkdir -p /opt/osctrl/script && \
chown osctrl-${COMPONENT}:osctrl-${COMPONENT} -R /opt/osctrl

COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
RUN chmod 755 /opt/osctrl/bin/osctrl-${COMPONENT}

COPY deploy/docker/conf/osctrl/db.json /opt/osctrl/config/db.json

COPY deploy/docker/conf/osctrl/cli/entrypoint.sh /entrypoint.sh
COPY deploy/docker/conf/cli/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh

USER osctrl-${COMPONENT}
Expand Down
2 changes: 1 addition & 1 deletion deploy/cicd/docker/Dockerfile-osctrl-tls
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ARG GOARCH=amd64

# Install software
RUN apt-get update -y -q && \
apt-get install curl -y && \
rm -rf /var/lib/apt/lists/*

# Install/Setup osctrl
RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin && \
mkdir -p /opt/osctrl/config && \
mkdir -p /opt/osctrl/script && \
chown osctrl-${COMPONENT}:osctrl-${COMPONENT} -R /opt/osctrl
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
RUN chmod 755 /opt/osctrl/bin/osctrl-${COMPONENT}
Expand Down
3 changes: 0 additions & 3 deletions deploy/docker/.gitignore

This file was deleted.

156 changes: 0 additions & 156 deletions deploy/docker/Dockerfile-osctrl-dev

This file was deleted.

Loading

0 comments on commit 94e0afb

Please sign in to comment.