Skip to content

Commit

Permalink
Fix not exposing port in taginfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Apr 15, 2024
1 parent 27eca15 commit edf1985
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
10 changes: 5 additions & 5 deletions compose/taginfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ services:
context: ../images/taginfo
dockerfile: Dockerfile
ports:
- '4567:80'
- '8000:80'
volumes:
- ../data/taginfo-data:/apps/data/
- ../data/taginfo-data:/usr/src/app/data
command: >
/bin/bash -c "
./start.sh"
/bin/bash -c "/usr/src/app/start.sh web"
env_file:
- ../envs/.env.taginfo
- ../envs/.env.taginfo
47 changes: 31 additions & 16 deletions images/taginfo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM ruby:3.0 as builder
FROM ruby:3.0-slim

ARG workdir=/usr/src/app
WORKDIR $workdir

RUN apt-get update && apt-get install -y \
cmake \
libbz2-dev \
Expand All @@ -20,39 +22,52 @@ RUN apt-get update && apt-get install -y \
libreadline-dev \
tcl \
git \
jq \
python3-pip \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Clone and setup taginfo-tools
RUN git clone https://github.com/taginfo/taginfo-tools.git $workdir/taginfo-tools && \
cd $workdir/taginfo-tools && \
git submodule update --init && \
mkdir build && cd build && \
cmake .. && make

RUN apt-get update && apt-get install -y \
passenger \
libapache2-mod-passenger \
git \
jq \
python3-pip \
wget \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN gem install json rack-contrib puma
RUN gem install sinatra -v '< 3'
RUN gem install sinatra-r18n -v '5.0.2'
RUN gem install json rack-contrib puma sinatra:'<3' sinatra-r18n:'5.0.2'

# Install AWS CLI
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm awscliv2.zip

# Clone and setup taginfo
RUN git clone https://github.com/taginfo/taginfo.git $workdir/taginfo && \
cd $workdir/taginfo && \
bundle install

# Download and prepare uWSGI
RUN wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz \
&& tar zxvf uwsgi-latest.tar.gz \
&& rm uwsgi-latest.tar.gz && \
mv $(ls | grep uwsgi-) uwsgi-dir && \
cd uwsgi-dir && \
make PROFILE=nolang && \
PYTHON=python3 UWSGI_PROFILE_OVERRIDE="ssl=true,rack=true,http=true" make

# # Set non-root user
# RUN groupadd -r taginfo && useradd -m -r -g taginfo taginfo
# RUN chown -R taginfo:taginfo $workdir
# RUN chmod -R 777 $workdir
# USER taginfo

# RUN chown -R www-data: $workdir

WORKDIR $workdir

# Copy configuration files and scripts
COPY config/taginfo-config.json $workdir/
COPY start.sh .

# Expose port and set default command
EXPOSE 80
CMD ["./start.sh"]
2 changes: 1 addition & 1 deletion images/taginfo/config/taginfo-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"instance": {
"url": "http://localhost:4567",
"url": "http://localhost:80",
"name": "OpenStreetMap Taginfo",
"description": "This is a <b>taginfo test instance</b>. Change this text in your <tt>taginfo-config.json</tt>.",
"about": "<p>This site is maintained by osm-seed",
Expand Down
6 changes: 3 additions & 3 deletions images/taginfo/start.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env bash
WORKDIR=/usr/src/app
DATADIR=/usr/src/app/data
DATADOWNLOAD=/osm/planet/var
DATADOWNLOAD=/usr/src/app/osm
mkdir -p $DATADIR/
mkdir -p $DATADOWNLOAD/
mkdir -p $DATA_DIR/update/log/
mkdir -p $DATADIR/update/log/

updates_source_code() {
echo "Update...Procesor source code"
sed -i 's/"env -/"/g' $WORKDIR/taginfo/sources/util.sh
sed -i '/configure do/a \ \ \ \ set :port, 80' $WORKDIR/taginfo/web/taginfo.rb
sed -i "/configure do/a \ \ \ \ set :bind, '0.0.0.0'" $WORKDIR/taginfo/web/taginfo.rb
# Function to replace the projects repo to get the projects information
TAGINFO_PROJECT_REPO=${TAGINFO_PROJECT_REPO//\//\\/}
sed -i -e 's/https:\/\/github.com\/taginfo\/taginfo-projects.git/'$TAGINFO_PROJECT_REPO'/g' $WORKDIR/taginfo/sources/projects/update.sh
Expand Down Expand Up @@ -55,7 +56,6 @@ start_web() {
if ! aws s3 ls "s3://$BUCKET_NAME/$ENVIRONMENT" 2>&1 | grep -q 'An error occurred'; then
aws s3 sync s3://$AWS_S3_BUCKET/$ENVIRONMENT/ $DATADIR/
fi
# cd $WORKDIR/taginfo/web && bundle exec uwsgi uwsgi.ini
cd $WORKDIR/taginfo/web && ./taginfo.rb
}

Expand Down

0 comments on commit edf1985

Please sign in to comment.