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

Improve docker-compose installation method: #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ services:
- .env
networks:
app_net:
ipv4_address: $VOYAGER_SERVER_IPV4_ADDR
ipv4_address: ${VOYAGER_SERVER_IPV4_ADDR}
ports: #host:container
- $VOYAGER_SERVER_PORT:$VOYAGER_SERVER_PORT
- ${VOYAGER_SERVER_PORT}:${VOYAGER_SERVER_PORT}
volumes:
- .:/app

networks:
app_net:
ipam:
driver: default
config:
- subnet: $VOYAGER_SERVER_SUBNET
- subnet: ${VOYAGER_SERVER_SUBNET}
74 changes: 58 additions & 16 deletions services/server/setup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,68 @@

FROM ubuntu:20.04

# Install provisioning and startup scripts
# Set environment variables
ENV USER voyager
ENV NVM_DIR "/home/$USER/.nvm"
ENV NVM_VERSION 0.35.1
ENV NODE_VERSION 16.20.2
ENV NPM_VERSION 7.5.6

# Copy script files to container
COPY *.sh /var/scripts/
WORKDIR /var/scripts

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y apt-utils \
&& apt-get install -y dos2unix \
&& dos2unix *.sh
# Install necessary packages
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
vim \
wget \
dos2unix \
curl \
bzip2 \
git \
build-essential \
ca-certificates \
libssl-dev \
python3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Run provisioning scripts
RUN bash -C './provision.sh'
# Change line endings to Unix format
RUN dos2unix ./*.sh

# Set startup directory
WORKDIR /app
# Create user and directory for application
RUN useradd -m "$USER" && \
mkdir /app && \
chown -R "$USER":"$USER" /app

# Switch to non-root user
USER $USER

RUN git config --global --add safe.directory /app

# Install Node.js using NVM
RUN curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh" | bash && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \
nvm install "$NODE_VERSION" && \
nvm use "$NODE_VERSION" && \
nvm alias default "$NODE_VERSION" && \
npm install -g "npm@$NPM_VERSION"

# Cleanup
RUN apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="/home/$USER/.nvm/versions/node/v$NODE_VERSION/bin:$PATH"

# Verify Node.js and npm installation
RUN node --version && \
npm --version

# Add helpful bash aliases
RUN echo "alias ll='ls -la'" >> "/home/$USER/.bashrc" && \
echo "alias ..='cd ..'" >> "/home/$USER/.bashrc"

# Set working directory
WORKDIR /app

# Entrypoint
CMD bash -C '/var/scripts/start.sh'
# Define entrypoint
CMD ["/bin/bash", "/var/scripts/start.sh"]
38 changes: 0 additions & 38 deletions services/server/setup/provision.sh

This file was deleted.

5 changes: 2 additions & 3 deletions services/server/setup/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# NODE SERVER ENTRYPOINT

# make sure path for node, npm and module binaries is registered
source /root/.nvm/nvm.sh
source ~/.nvm/nvm.sh

# install/update node module dependencies
cd /app
cd /app || exit
npm install

# build server code in services/server/bin/
Expand All @@ -21,4 +21,3 @@ fi

# start server in debug mode
npm run server