Skip to content

Commit

Permalink
feat: support runas user
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Lauber <jan.lauber@protonmail.ch>
  • Loading branch information
janlauber committed May 8, 2024
1 parent 76ef841 commit 6e91684
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ FROM google/cloud-sdk:latest
# Install MySQL client
RUN apt-get update && apt-get install -y default-mysql-client

# Create a directory for the backup
# Create a non-root user and group
# Note: Ensure the user and group IDs do not conflict with IDs on the host or in other containers
RUN groupadd -r mysqlbackup -g 3000 && \
useradd -r -g mysqlbackup -u 1001 -m -d /backup mysqlbackup

# Create a directory for the backup and set permissions
WORKDIR /backup
RUN chown mysqlbackup:mysqlbackup /backup

# Copy the backup script into the container
COPY backup.sh /backup/backup.sh

# Make the backup script executable
RUN chmod +x /backup/backup.sh
RUN chown mysqlbackup:mysqlbackup /backup/backup.sh

# Use the non-root user to run the container
USER mysqlbackup

# Set the entry point to the backup script
ENTRYPOINT ["/backup/backup.sh"]

0 comments on commit 6e91684

Please sign in to comment.