Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-1674] Remove daemon submodule use image from dockerhub #37

Merged
merged 7 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Autodetect text files
* text=auto
# Ensure text files uses LF.
* text=lf

# Ensure shell script uses LF.
# Ensure shell script uses LF and bat script CRLF.
Dockerfile eol=lf
*.sh eol=lf
.env eol=lf
*.bat eol=crlf
.env eol=lf
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

16 changes: 8 additions & 8 deletions configs/core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage: setup-web-server
FROM php:apache-buster as setup-web-server
FROM php:apache-buster AS setup-web-server

# Install dependencies
RUN apt-get update -y && \
Expand All @@ -20,7 +20,7 @@ RUN docker-php-ext-install ffi pdo pdo_mysql gmp bcmath sodium mysqli sockets pc
RUN docker-php-ext-enable redis imagick

# Stage: create-application
FROM setup-web-server as create-application
FROM setup-web-server AS create-application

WORKDIR /app/
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
Expand All @@ -32,7 +32,7 @@ COPY configs/core/config/ /app/laravel-application/config/
COPY configs/core/routes/ /app/laravel-application/routes/

# Stage: composer-update
FROM create-application as composer-update
FROM create-application AS composer-update

RUN cd laravel-application && \
composer update --prefer-dist --no-dev --optimize-autoloader --no-interaction --ignore-platform-reqs
Expand All @@ -41,7 +41,7 @@ RUN cd laravel-application && \
RUN cd /app/laravel-application/vendor/gmajor/sr25519-bindings/go && go build -buildmode=c-shared -o sr25519.so . && mv sr25519.so ../src/Crypto/sr25519.so

# Stage: http setup
FROM create-application as http-setup
FROM create-application AS http-setup

# Set ServerName to be localhost.
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
Expand Down Expand Up @@ -69,16 +69,16 @@ COPY configs/core/php /usr/local/etc/php/conf.d
COPY configs/core/supervisor /etc/supervisor

# Stage: platform-core
FROM http-setup as enjin-platform
FROM http-setup AS enjin-platform

LABEL org.opencontainers.image.source=https://github.com/enjin/platform
LABEL org.opencontainers.image.description="Enjin Platform - The most powerful and advanced open-source framework for building NFT platforms."
LABEL org.opencontainers.image.licenses=LGPL-3.0-only

WORKDIR /var/www/html

COPY configs/core/start.sh /usr/local/bin/start
RUN dos2unix /usr/local/bin/start
COPY configs/core/start.sh /usr/local/bin/start.sh
RUN dos2unix /usr/local/bin/start.sh

USER www-data
CMD ["/usr/local/bin/start"]
CMD ["/usr/local/bin/start.sh"]
8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- "${REDIS_EXTERNAL_PORT}:6379"

decoder:
platform: linux/x86_64
platform: linux/amd64
image: enjin/platform-decoder:latest
restart: unless-stopped
ports:
Expand Down Expand Up @@ -107,10 +107,8 @@ services:
- "host.docker.internal:host-gateway"

daemon:
image: enjin/daemon:latest
build:
context: ./wallet-daemon
dockerfile: Dockerfile
platform: linux/amd64
image: enjin/wallet-daemon:latest
restart: unless-stopped
env_file:
- ./configs/daemon/.env
Expand Down
16 changes: 5 additions & 11 deletions start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ goto :EOF
:check_and_generate_app_key
:: Check if $APP_KEY is already set
set "APP_KEY="
for /f "tokens=2 delims==" %%i in ('findstr /r /c:"APP_KEY=" configs\core\.env') do (
for /f "tokens=2 delims==" %%i in ('findstr /r /c:"^APP_KEY=" configs\core\.env') do (
set "APP_KEY=%%i"
)
:: If not set, generate a new key automatically
Expand Down Expand Up @@ -128,7 +128,7 @@ for /f "tokens=2 delims==" %%i in ('findstr /r /c:"DAEMON_ACCOUNT=" configs\core
if "%DAEMON_ACCOUNT%"=="" (
echo Let's get your wallet daemon address, please wait...
(docker compose up -d daemon)
for /f "delims=" %%a in ('docker compose logs daemon 2^>^&1 ^| findstr /r /c:"Efinity:"') do (
for /f "delims=" %%a in ('docker compose logs daemon 2^>^&1 ^| findstr /r /c:"Matrix:"') do (
for %%w in (%%a) do set "WALLET_ADDRESS=%%w"
)
echo Your wallet daemon address is: !WALLET_ADDRESS!
Expand Down Expand Up @@ -187,25 +187,19 @@ goto :EOF
:MAIN
echo Welcome to Enjin Platform, this script will help you start it up
call :check_git_is_installed

:: Initialize Git submodules
git submodule update --init

call :check_has_app_url
call :check_has_basic_token
call :check_has_daemon_password
call :check_and_generate_app_key

:: Build the daemon container
docker compose build daemon
call :get_daemon_address

:: Prompt the user to start platform services
set /p start_services=Do you want to start all platform services? (y/n)
if /i "%start_services%"=="y" (
docker compose build
docker compose build app --no-cache
docker compose up -d
echo Your Enjin Platform is now running, please visit: http://127.0.0.1:8000
echo Your Enjin Platform is now installing the UI and other dependencies...
echo It should be available in a few minutes at: http://127.0.0.1:8000
) else (
docker compose down
echo Please run this script again when you are ready
Expand Down
20 changes: 11 additions & 9 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ get_daemon_address() {
DAEMON_ACCOUNT=$(awk '$1 ~ /^DAEMON_ACCOUNT/' configs/core/.env | cut -d "=" -f 2)
if [ -z "$DAEMON_ACCOUNT" ]; then
echo "Let's get your wallet daemon address, please wait..."

(docker compose up -d daemon)
WALLET_ADDRESS=$(docker compose logs daemon 2>&1 | grep "Efinity:" | awk '{print $NF}' | tail -n 1)
echo "Your wallet daemon address is: $WALLET_ADDRESS"
sleep 3

WALLET_ADDRESS=$(docker compose logs daemon 2>&1 | grep -A2 "Wallet daemon address" | awk '{print $NF}' | tail -n 2)
echo "Your wallet daemon address is:"
echo "$WALLET_ADDRESS"
WALLET_ADDRESS=$(echo "$WALLET_ADDRESS" | head -n 1)

if [ "$PLATFORM_OS" = "macOS" ]; then
sed -i '' -e "s/^DAEMON_ACCOUNT=/DAEMON_ACCOUNT=$WALLET_ADDRESS/g" configs/core/.env
Expand Down Expand Up @@ -160,30 +165,27 @@ check_git_is_installed() {
}

echo "Welcome to Enjin Platform, this script will help you start it up"

detect_user_os
check_git_is_installed
check_openssl_is_installed
check_docker_is_installed
check_compose_is_installed
check_docker_is_running

git submodule update --init

check_has_app_url
check_has_basic_token
check_has_daemon_password
check_and_generate_app_key

docker compose build daemon
get_daemon_address

echo "Do you want to start all platform services? (y/n)"
read start_services

if [ "$start_services" != "${start_services#[Yy]}" ] ;then
docker compose build
docker compose build app --no-cache
docker compose up -d
echo "Your Enjin Platform is now running, please visit: http://127.0.0.1:8000"
echo "Your Enjin Platform is now installing the UI and other dependencies..."
echo "It should be available in a few minutes at: http://127.0.0.1:8000 "
else
docker compose down
echo "Please run this script again when you are ready"
Expand Down