tarantool / docker

Docker images for tarantool database
https://hub.docker.com/r/tarantool/tarantool
52 stars 25 forks source link

SystemError: can't open log file: /opt/tarantool/tarantool.log: Permission denied #271

Closed mymtw closed 5 months ago

mymtw commented 6 months ago

docker compose

  tarantool:
    container_name: tarantool
    build:
      dockerfile: tarantool.Dockerfile
    restart: always
    environment:
      TARANTOOL_USER_NAME: test_user
      TARANTOOL_USER_PASSWORD: test_user
    volumes:
      - ./tarantool_data:/var/lib/tarantool
      - ./tarantool_conf:/opt/tarantool
    ports:
      - "3301:3301"

tarantool.Dockerfile


ENV TARANTOOL_USER_NAME test_user
ENV TARANTOOL_USER_PASSWORD test_user

COPY *.lua /opt/tarantool/
EXPOSE 3301
WORKDIR /opt/tarantool

CMD ["tarantool", "app.lua"]

app.lua


box.cfg{
    listen=3301,
    log = '/opt/tarantool/tarantool.log'

}

box.once("bootstrap", function()
    box.schema.space.create('user_ads_stats_notifications_schema')

    box.space.user_ads_stats_notifications_schema:format({
        { name = 'id', type = 'unsigned' },
        { name = 'ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'found_ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'wrong_token_error', type = 'integer', default = 0, is_nullable = true },
        { name = 'seller_delievery', type = 'integer', default = 0, is_nullable = true },
        { name = 'seller_rating', type = 'integer', default = 0, is_nullable = true },
        { name = 'paid_ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'wrong_price_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'wrong_ad_created_at', type = 'integer', default = 0, is_nullable = true },
        { name = 'wrong_seller_created_at', type = 'integer', default = 0, is_nullable = true },
        { name = 'max_ads_per_seller', type = 'integer', default = 0, is_nullable = true },
        { name = 'max_ad_views_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'user_repeat_ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'sellers_without_phones_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'local_black_list_ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'global_black_list_ads_count', type = 'integer', default = 0, is_nullable = true },
        { name = 'seller_count_of_sells', type = 'integer', default = 0, is_nullable = true },
        { name = 'seller_total_buys', type = 'integer', default = 0, is_nullable = true },
    })

    box.space.user_ads_stats_notifications_schema:create_index('primary', { parts = { 'id' } })
    box.space.user_ads_stats_notifications_schema:insert { 1, 0 }
end)

получаю ошибку


failed to initialize logging subsystem
Loading existing configuration file: /etc/tarantool/config.yml
Config:
---
log_format: plain
log: tarantool.log
vinyl_dir: /var/lib/tarantool
wal_dir: /var/lib/tarantool
memtx_dir: /var/lib/tarantool
pid_file: /var/run/tarantool/tarantool.pid
listen: 3301
log_level: 5
force_recovery: false
...

SystemError: can't open log file: /opt/tarantool/tarantool.log: Permission denied
failed to initialize logging subsystem```
mymtw commented 5 months ago
FROM tarantool/tarantool:2.11.2

# Установка пакета для создания группы и пользователя
RUN apk --no-cache add shadow

# Создание группы и пользователя
ARG PUID=1000
ARG PGID=1000
ENV TARANTOOL_USER_NAME=test_user
ENV TARANTOOL_USER_PASSWORD=test_user

RUN mkdir -p /var/log/tarantool
RUN chown -R tarantool:tarantool /var/log/tarantool && chown -R tarantool:tarantool /var/log/

USER tarantool

COPY *.lua /opt/tarantool/

EXPOSE 3301
WORKDIR /opt/tarantool

# Изменение владельца и разрешений на файл
USER tarantool

CMD ["tarantool", "app.lua"]