Skip to content

Commit

Permalink
Update Docker environment
Browse files Browse the repository at this point in the history
- Remove build.md which was included by mistake.
- Improve dev.sh script.
- Update .gitignore to exclude artifacts folder.
- Create .dockerignore file.
- Replace get_version.sh script with inline command.
- Reduce image size by using alpine as base image.
  • Loading branch information
AlexRuiz7 committed Nov 29, 2023
1 parent 7641fca commit b80f99d
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
artifacts/

# intellij files
.idea/
Expand Down
40 changes: 28 additions & 12 deletions docker/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,57 @@

# Attaches the project as a volume to a JDK 17 container
# Requires Docker
# Script usage: bash ./docker.sh
# Script usage: bash ./dev.sh

set -e

# Change working directory to the root of the repository
cd "${0%/*}/.."
# ====
# Checks that the script is run from the intended location
# ====
function check_project_root_folder () {
if [[ "$0" != "./dev.sh" && "$0" != "dev.sh" ]]; then
echo "Run the script from its location"
usage
exit 1
fi
# Change working directory to the root of the repository
cd ..
}

# ====
# Displays usage
# ====
function usage() {
echo "Usage: ./dev.sh {up|down|stop}"
}

# ====
# Main function
# ====
main() {
COMPOSE_FILE=docker/dev.yml
function main() {
check_project_root_folder "$@"
compose_file=docker/dev.yml
compose_cmd="docker compose -f $compose_file"
REPO_PATH=$(pwd)
VERSION=$(bash "$REPO_PATH/docker/get_version.sh")
COMPOSE_CMD="docker compose -f $COMPOSE_FILE"
VERSION=$(cat VERSION)
export REPO_PATH
export VERSION

case $1 in
up)
$COMPOSE_CMD up -d
$compose_cmd up -d
;;
down)
$COMPOSE_CMD down
$compose_cmd down
;;
stop)
$COMPOSE_CMD stop
$compose_cmd stop
;;
*)
echo "Usage: $0 {up|down|stop} [security]"
usage
exit 1
;;
esac
}


main "$@"
5 changes: 0 additions & 5 deletions docker/get_version.sh

This file was deleted.

67 changes: 67 additions & 0 deletions docker/images/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
artifacts/

# intellij files
.idea/
*.iml
*.ipr
*.iws
build-idea/
out/

# include shared intellij config
!.idea/inspectionProfiles/Project_Default.xml
!.idea/runConfigurations/Debug_OpenSearch.xml
!.idea/vcs.xml

# These files are generated in the main tree by annotation processors
benchmarks/src/main/generated/*
benchmarks/bin/*
benchmarks/build-eclipse-default/*
server/bin/*
server/build-eclipse-default/*
test/framework/build-eclipse-default/*

# eclipse files
.project
.classpath
.settings
build-eclipse/

# netbeans files
nb-configuration.xml
nbactions.xml

# gradle stuff
.gradle/
build/

# vscode stuff
.vscode/

# testing stuff
**/.local*
.vagrant/
/logs/

# osx stuff
.DS_Store

# default folders in which the create_bwc_index.py expects to find old es versions in
/backwards
/dev-tools/backwards

# needed in case docs build is run...maybe we can configure doc build to generate files under build?
html_docs

# random old stuff that we should look at the necessity of...
/tmp/
eclipse-build

# projects using testfixtures
testfixtures_shared/

# These are generated from .ci/jobs.t
.ci/jobs/

# build files generated
doc-tools/missing-doclet/bin/
6 changes: 3 additions & 3 deletions docker/images/wi-dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ COPY --chown=gradle:gradle . /home/wazuh-indexer/app
RUN gradle clean


FROM eclipse-temurin:17
RUN groupadd -g 1000 wazuh-indexer && \
adduser --uid 1000 --gid 1000 --home /home/wazuh-indexer wazuh-indexer && \
FROM eclipse-temurin:17-jdk-alpine
RUN addgroup -g 1000 wazuh-indexer && \
adduser -u 1000 -G wazuh-indexer -D -h /home/wazuh-indexer wazuh-indexer && \
chmod 0775 /home/wazuh-indexer && \
chown -R 1000:0 /home/wazuh-indexer
USER wazuh-indexer
Expand Down
104 changes: 0 additions & 104 deletions scripts/build.md

This file was deleted.

0 comments on commit b80f99d

Please sign in to comment.