diff --git a/.circleci/config.yml b/.circleci/config.yml index 9adde9a..ec169e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,38 @@ jobs: name: install dependencies command: sudo apt-get install bash curl + - run: + name: download Go + command: wget https://golang.org/dl/go1.20.2.linux-amd64.tar.gz + + - run: + name: install Go + command: sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz + + - run: + name: set Go path + command: echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV + + - run: | + echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV + echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV + + - run: | + node -v + + - run: | + nvm install v16 + node -v + nvm alias default v16 + + - run: | + node -v + - run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD + + - run: + name: Install dependencies + command: npm install - run: name: Download GeoLite2-Country database @@ -19,6 +50,10 @@ jobs: curl -s -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=$MAX_TOKEN&suffix=tar.gz" -o GeoLite2-Country.tar.gz tar -xzf GeoLite2-Country.tar.gz --strip-components 1 --wildcards "*.mmdb" + - run: + name: Build UI + command: npm run client-build + - run: name: Build and publish dockerfiles command: sh docker.sh @@ -35,7 +70,38 @@ jobs: name: install dependencies command: sudo apt-get install bash curl + - run: + name: download Go + command: wget https://golang.org/dl/go1.20.2.linux-arm64.tar.gz + + - run: + name: install Go + command: sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.20.2.linux-arm64.tar.gz + + - run: + name: set Go path + command: echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV + + - run: | + echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV + echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV + + - run: | + node -v + + - run: | + nvm install v16 + node -v + nvm alias default v16 + + - run: | + node -v + - run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD + + - run: + name: Install dependencies + command: npm install - run: name: Download GeoLite2-Country database @@ -43,6 +109,10 @@ jobs: curl -s -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=$MAX_TOKEN&suffix=tar.gz" -o GeoLite2-Country.tar.gz tar -xzf GeoLite2-Country.tar.gz --strip-components 1 --wildcards "*.mmdb" + - run: + name: Build UI + command: npm run client-build + - run: name: Build and publish dockerfiles command: sh docker.arm64.sh diff --git a/docker.arm64.sh b/docker.arm64.sh index c17c430..6e5c69d 100644 --- a/docker.arm64.sh +++ b/docker.arm64.sh @@ -12,6 +12,8 @@ fi echo "Pushing azukaar/cosmos-server:$VERSION and azukaar/cosmos-server:$LATEST" +sh build.arm64.sh + docker build \ -t azukaar/cosmos-server:$VERSION-arm64 \ -t azukaar/cosmos-server:$LATEST-arm64 \ diff --git a/docker.sh b/docker.sh index 32ac9e3..baeb613 100644 --- a/docker.sh +++ b/docker.sh @@ -12,6 +12,8 @@ fi echo "Pushing azukaar/cosmos-server:$VERSION and azukaar/cosmos-server:$LATEST" +sh build.sh + docker build \ -t azukaar/cosmos-server:$VERSION \ -t azukaar/cosmos-server:$LATEST \ diff --git a/dockerfile b/dockerfile index bbda2b6..72af658 100644 --- a/dockerfile +++ b/dockerfile @@ -6,38 +6,15 @@ EXPOSE 443 80 VOLUME /config +RUN apt-get update && apt-get install -y ca-certificates openssl + WORKDIR /app -ENV PATH=$PATH:/usr/local/go/bin +COPY build/cosmos . +COPY build/cosmos_gray.png . +COPY build/Logo.png . +COPY build/GeoLite2-Country.mmdb . +COPY build/meta.json . +COPY static ./static -RUN apt-get update && apt-get install -y ca-certificates openssl && \ - apt-get install -y --no-install-recommends wget curl && \ - apt-get install -y --no-install-recommends nodejs && \ - wget https://golang.org/dl/go1.20.2.linux-amd64.tar.gz && \ - tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz && \ - rm go1.20.2.linux-amd64.tar.gz && \ - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ - apt-get install -y nodejs && \ - apt-get remove -y wget curl && \ - apt-get autoremove -y - -COPY go.mod ./ -COPY go.sum ./ -RUN go mod download - -COPY package.json ./ -COPY package-lock.json ./ -RUN npm install - -COPY . . -RUN npm run client-build && \ - chmod +x build.sh && \ - ./build.sh && \ - rm -rf /usr/local/go \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* - -WORKDIR /app/build - -CMD ["./cosmos"] +CMD ["./cosmos"] \ No newline at end of file diff --git a/dockerfile.arm64 b/dockerfile.arm64 index dccf3d6..f9cc89d 100644 --- a/dockerfile.arm64 +++ b/dockerfile.arm64 @@ -6,38 +6,17 @@ EXPOSE 443 80 VOLUME /config +RUN apt-get clean +RUN apt-get update +RUN apt-get install -y ca-certificates openssl + WORKDIR /app -ENV PATH=$PATH:/usr/local/go/bin +COPY build/cosmos . +COPY build/cosmos_gray.png . +COPY build/Logo.png . +COPY build/GeoLite2-Country.mmdb . +COPY build/meta.json . +COPY static ./static -RUN apt-get update && apt-get install -y ca-certificates openssl && \ - apt-get install -y --no-install-recommends wget curl && \ - apt-get install -y --no-install-recommends nodejs && \ - wget https://golang.org/dl/go1.20.2.linux-arm64.tar.gz && \ - tar -C /usr/local -xzf go1.20.2.linux-arm64.tar.gz && \ - rm go1.20.2.linux-arm64.tar.gz && \ - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ - apt-get install -y nodejs && \ - apt-get remove -y wget curl && \ - apt-get autoremove -y - -COPY go.mod ./ -COPY go.sum ./ -RUN go mod download - -COPY package.json ./ -COPY package-lock.json ./ -RUN npm install - -COPY . . -RUN npm run client-build && \ - chmod +x build.sh && \ - ./build.sh && \ - rm -rf /usr/local/go \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* - -WORKDIR /app/build - -CMD ["./cosmos"] +CMD ["./cosmos"] \ No newline at end of file diff --git a/dockerfile.local b/dockerfile.local new file mode 100644 index 0000000..bbda2b6 --- /dev/null +++ b/dockerfile.local @@ -0,0 +1,43 @@ +# syntax=docker/dockerfile:1 + +FROM debian + +EXPOSE 443 80 + +VOLUME /config + +WORKDIR /app + +ENV PATH=$PATH:/usr/local/go/bin + +RUN apt-get update && apt-get install -y ca-certificates openssl && \ + apt-get install -y --no-install-recommends wget curl && \ + apt-get install -y --no-install-recommends nodejs && \ + wget https://golang.org/dl/go1.20.2.linux-amd64.tar.gz && \ + tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz && \ + rm go1.20.2.linux-amd64.tar.gz && \ + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + apt-get remove -y wget curl && \ + apt-get autoremove -y + +COPY go.mod ./ +COPY go.sum ./ +RUN go mod download + +COPY package.json ./ +COPY package-lock.json ./ +RUN npm install + +COPY . . +RUN npm run client-build && \ + chmod +x build.sh && \ + ./build.sh && \ + rm -rf /usr/local/go \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* + +WORKDIR /app/build + +CMD ["./cosmos"] diff --git a/package.json b/package.json index 2be8a70..1a56168 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "start": "env COSMOS_HOSTNAME=localhost CONFIG_FILE=./config_dev.json EZ=UTC build/cosmos", "build": "sh build.sh", "dev": "npm run build && npm run start", - "dockerdevbuild": "sh build.sh && docker build --tag cosmos-dev .", + "dockerdevbuild": "sh build.sh && docker build -f dockerfile.local --tag cosmos-dev .", "dockerdevrun": "docker stop cosmos-dev; docker rm cosmos-dev; docker run -d -p 80:80 -p 443:443 -e DOCKER_HOST=tcp://host.docker.internal:2375 -e COSMOS_MONGODB=$MONGODB -e COSMOS_LOG_LEVEL=DEBUG -v /:/mnt/host --restart=unless-stopped -h cosmos-dev --name cosmos-dev cosmos-dev", "dockerdev": "npm run dockerdevbuild && npm run dockerdevrun", "dockerdevclient": "npm run client-build && npm run dockerdevbuild && npm run dockerdevrun",