Skip to content

Commit 184d424

Browse files
f-gallandAlexRuiz7
andcommitted
Get Wazuh version from VERSION file (#122)
* Add function to look for VERSION in the correct path * Update assemble.sh Adds wget as dependency * Download files using curl instead of wget * Update assemble.sh Revert assembly with minimal plugins for testing Signed-off-by: Álex Ruiz <[email protected]> * Add Dockerfile and docker-compose for the package assembly stage * Assemble packages with minimal plugin set when "test" variable is set to "true" * Update README with assemble.sh docker image * Fixing env variable naming convention and removing wget dependency * Improve Docker environments Adds environments to build packages * Fix small typos * More fixes * Add documentation * Adding -p flag to mkdir so it doesnt fail when the folder is already present * Format files --------- Signed-off-by: Álex Ruiz <[email protected]> Co-authored-by: Álex Ruiz <[email protected]>
1 parent 9a2c904 commit 184d424

13 files changed

+283
-121
lines changed

docker/README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,28 @@ Docker Desktop will change to its context automatically at start, so be sure
5151
that any existing Docker container using the default context is **stopped**
5252
before starting Docker Desktop and any of the environments in this folder.
5353

54-
## Starting up the environments
54+
## Development environments
5555

56-
Use the sh script to up the environment.
56+
Use the `dev/dev.sh` script to start a development environment.
5757

5858
Example:
5959

6060
```bash
61-
Usage: ./dev.sh {up|down|stop} [security]
61+
Usage: ./dev.sh {up|down|stop}
6262
```
6363

64-
Once the `wazuh-indexer` container is up, attach a shell to it and run `./gradlew run`
64+
Once the `wi-dev:x.y.z` container is up, attach a shell to it and run `./gradlew run`
6565
to start the application.
6666

67+
## Containers to generate packages
68+
69+
Use the `ci/ci.sh` script to start provisioned containers to generate packages.
70+
71+
```bash
72+
Usage: ./ci.sh {up|down|stop} [ci]
73+
```
74+
75+
Refer to [scripts/README.md](../scripts/README.md) for details about how to build packages.
6776

6877
[docker-desktop]: https://docs.docker.com/get-docker
6978
[docker-variant]: https://docs.docker.com/desktop/install/linux-install/#differences-between-docker-desktop-for-linux-and-docker-engine

docker/ci/ci.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# Start container with required tools to build packages
4+
# Requires Docker
5+
# Script usage: bash ./ci.sh
6+
7+
set -e
8+
9+
# ====
10+
# Checks that the script is run from the intended location
11+
# ====
12+
function check_project_root_folder() {
13+
current=$(basename "$(pwd)")
14+
15+
if [[ "$0" != "./ci.sh" && "$0" != "ci.sh" ]]; then
16+
echo "Run the script from its location"
17+
usage
18+
exit 1
19+
fi
20+
# Change working directory to the root of the repository
21+
cd ../..
22+
}
23+
24+
# ====
25+
# Displays usage
26+
# ====
27+
function usage() {
28+
echo "Usage: ./ci.sh {up|down|stop}"
29+
}
30+
31+
# ====
32+
# Main function
33+
# ====
34+
function main() {
35+
check_project_root_folder "$@"
36+
compose_file="docker/${current}/ci.yml"
37+
compose_cmd="docker compose -f $compose_file"
38+
REPO_PATH=$(pwd)
39+
VERSION=$(cat VERSION)
40+
export REPO_PATH
41+
export VERSION
42+
43+
case $1 in
44+
up)
45+
# Main folder created here to grant access to both containers
46+
mkdir -p artifacts
47+
$compose_cmd up -d
48+
;;
49+
down)
50+
$compose_cmd down
51+
;;
52+
stop)
53+
$compose_cmd stop
54+
;;
55+
*)
56+
usage
57+
exit 1
58+
;;
59+
esac
60+
}
61+
62+
main "$@"

docker/ci/ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "3.9"
2+
3+
services:
4+
# Essentially wi-dev, but doesn't expose port 9200
5+
wi-build:
6+
image: wi-build:${VERSION}
7+
container_name: wi-build_${VERSION}
8+
build:
9+
context: ./../..
10+
dockerfile: ${REPO_PATH}/docker/dev/images/Dockerfile
11+
volumes:
12+
- ${REPO_PATH}:/home/wazuh-indexer
13+
entrypoint: ["tail", "-f", "/dev/null"]
14+
user: "1000:1000"
15+
working_dir: /home/wazuh-indexer
16+
17+
wi-assemble:
18+
image: wi-assemble:${VERSION}
19+
container_name: wi-assemble_${VERSION}
20+
build:
21+
context: ./../..
22+
dockerfile: ${REPO_PATH}/docker/ci/images/Dockerfile
23+
volumes:
24+
- ${REPO_PATH}/scripts:/home/wazuh-indexer/scripts
25+
- ${REPO_PATH}/artifacts:/home/wazuh-indexer/artifacts
26+
- ${REPO_PATH}/distribution/packages/src:/home/wazuh-indexer/distribution/packages/src
27+
entrypoint: ["tail", "-f", "/dev/null"]
28+
user: "1000:1000"
29+
working_dir: /home/wazuh-indexer
File renamed without changes.

docker/ci/images/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM ubuntu:jammy
2+
RUN mkdir /home/wazuh-indexer && \
3+
apt-get update -y && \
4+
apt-get install curl gnupg2 -y && \
5+
curl -o- https://www.aptly.info/pubkey.txt | apt-key add - && \
6+
echo "deb http://repo.aptly.info/ squeeze main" | tee -a /etc/apt/sources.list.d/aptly.list && \
7+
apt-get update -y && \
8+
apt-get upgrade -y && \
9+
apt-get install -y aptly build-essential cpio debhelper-compat debmake freeglut3 libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-dev libcairo2 libcairo2-dev libcups2 libdrm2 libgbm-dev libgconf-2-4 libnspr4 libnspr4-dev libnss3 libpangocairo-1.0-0 libxcomposite-dev libxdamage1 libxfixes-dev libxfixes3 libxi6 libxkbcommon-x11-0 libxrandr2 libxrender1 libxtst6 rpm rpm2cpio && \
10+
apt-get clean -y && \
11+
dpkg -r lintian && \
12+
addgroup --gid 1000 wazuh-indexer && \
13+
adduser --uid 1000 --ingroup wazuh-indexer --disabled-password --home /home/wazuh-indexer wazuh-indexer && \
14+
chmod 0775 /home/wazuh-indexer && \
15+
chown -R 1000:1000 /home/wazuh-indexer
16+
USER wazuh-indexer
17+
WORKDIR /home/wazuh-indexer

docker/dev.yml

-26
This file was deleted.

docker/dev.sh docker/dev/dev.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ set -e
99
# ====
1010
# Checks that the script is run from the intended location
1111
# ====
12-
function check_project_root_folder () {
12+
function check_project_root_folder() {
13+
current=$(basename "$(pwd)")
14+
1315
if [[ "$0" != "./dev.sh" && "$0" != "dev.sh" ]]; then
14-
echo "Run the script from its location"
16+
echo "Run the script from its location"
1517
usage
1618
exit 1
1719
fi
1820
# Change working directory to the root of the repository
19-
cd ..
21+
cd ../..
2022
}
2123

2224
# ====
@@ -31,7 +33,7 @@ function usage() {
3133
# ====
3234
function main() {
3335
check_project_root_folder "$@"
34-
compose_file=docker/dev.yml
36+
compose_file="docker/${current}/dev.yml"
3537
compose_cmd="docker compose -f $compose_file"
3638
REPO_PATH=$(pwd)
3739
VERSION=$(cat VERSION)
@@ -55,4 +57,4 @@ function main() {
5557
esac
5658
}
5759

58-
main "$@"
60+
main "$@"

docker/dev/dev.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "3.9"
2+
3+
services:
4+
wi-dev:
5+
image: wi-dev:${VERSION}
6+
container_name: wi-dev_${VERSION}
7+
build:
8+
context: ./../..
9+
dockerfile: ${REPO_PATH}/docker/dev/images/Dockerfile
10+
ports:
11+
# OpenSearch REST API
12+
- 9200:9200
13+
expose:
14+
- 9200
15+
volumes:
16+
- ${REPO_PATH}:/home/wazuh-indexer
17+
entrypoint: ["tail", "-f", "/dev/null"]
18+
user: "1000:1000"
19+
working_dir: /home/wazuh-indexer

docker/dev/images/.dockerignore

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
artifacts/
2+
.git/
3+
4+
# intellij files
5+
.idea/
6+
*.iml
7+
*.ipr
8+
*.iws
9+
build-idea/
10+
out/
11+
12+
# include shared intellij config
13+
!.idea/inspectionProfiles/Project_Default.xml
14+
!.idea/runConfigurations/Debug_OpenSearch.xml
15+
!.idea/vcs.xml
16+
17+
# These files are generated in the main tree by annotation processors
18+
benchmarks/src/main/generated/*
19+
benchmarks/bin/*
20+
benchmarks/build-eclipse-default/*
21+
server/bin/*
22+
server/build-eclipse-default/*
23+
test/framework/build-eclipse-default/*
24+
25+
# eclipse files
26+
.project
27+
.classpath
28+
.settings
29+
build-eclipse/
30+
31+
# netbeans files
32+
nb-configuration.xml
33+
nbactions.xml
34+
35+
# gradle stuff
36+
.gradle/
37+
build/
38+
39+
# vscode stuff
40+
.vscode/
41+
42+
# testing stuff
43+
**/.local*
44+
.vagrant/
45+
/logs/
46+
47+
# osx stuff
48+
.DS_Store
49+
50+
# default folders in which the create_bwc_index.py expects to find old es versions in
51+
/backwards
52+
/dev-tools/backwards
53+
54+
# needed in case docs build is run...maybe we can configure doc build to generate files under build?
55+
html_docs
56+
57+
# random old stuff that we should look at the necessity of...
58+
/tmp/
59+
eclipse-build
60+
61+
# projects using testfixtures
62+
testfixtures_shared/
63+
64+
# These are generated from .ci/jobs.t
65+
.ci/jobs/
66+
67+
# build files generated
68+
doc-tools/missing-doclet/bin/
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM gradle:jdk17-alpine AS builder
22
USER gradle
3-
WORKDIR /home/wazuh-indexer/app
4-
COPY --chown=gradle:gradle . /home/wazuh-indexer/app
3+
WORKDIR /home/wazuh-indexer
4+
COPY --chown=gradle:gradle . /home/wazuh-indexer
55
RUN gradle clean
66

77

@@ -12,7 +12,7 @@ RUN apk add git && \
1212
chmod 0775 /home/wazuh-indexer && \
1313
chown -R 1000:0 /home/wazuh-indexer
1414
USER wazuh-indexer
15-
COPY --from=builder --chown=1000:0 /home/wazuh-indexer/app /home/wazuh-indexer/app
16-
WORKDIR /home/wazuh-indexer/app
17-
RUN git config --global --add safe.directory /home/wazuh-indexer/app
15+
COPY --from=builder --chown=1000:0 /home/wazuh-indexer /home/wazuh-indexer
16+
WORKDIR /home/wazuh-indexer
17+
RUN git config --global --add safe.directory /home/wazuh-indexer
1818
EXPOSE 9200 9300

0 commit comments

Comments
 (0)