Skip to content

Commit

Permalink
modify structure
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinhuish committed Nov 8, 2020
1 parent a149765 commit 71a6f2e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.env
.env
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ services:
ports:
- 1433:1433
volumes:
- /docker/mssql/data:/data
- /docker/mssql/backup:/backup
- /docker/mssql/log:/log
- /docker/mssql/dump:/dump
- ./workspace/data:/data
- ./workspace/backup:/backup
- ./workspace/log:/log
- ./workspace/dump:/dump
restart: always
environment:
- TZ=Asia/Shanghai
Expand Down
20 changes: 13 additions & 7 deletions Dockerfile → builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ubuntu:18.04

ARG CONTAINER_PACKAGE_URL

ENV TZ=UTC \
ACCEPT_EULA=Y \
MSSQL_PID=Express \
Expand All @@ -10,24 +12,30 @@ ENV TZ=UTC \
MSSQL_MASTER_LOG_FILE=/var/opt/mssql/data/mastlog.ldf \
MSSQL_BACKUP_DIR=/backup \
MSSQL_DUMP_DIR=/dump \
MSSQL_ERROR_LOG_FILE=/log/err.log
MSSQL_ERROR_LOG_DIR=/log \
MSSQL_ERROR_LOG_FILE=${MSSQL_ERROR_LOG_DIR}/err.log \
DEBIAN_FRONTEND=noninteractive

VOLUME $MSSQL_DATA_DIR $MSSQL_BACKUP_DIR $MSSQL_ERROR_LOG_DIR $MSSQL_DUMP_DIR

COPY ./unlimited-memory.py /tmp/unlimited-memory.py

RUN export DEBIAN_FRONTEND=noninteractive && \
RUN if [ $CONTAINER_PACKAGE_URL ] ; then \
sed -i "s/security.ubuntu.com/${CONTAINER_PACKAGE_URL}/g" /etc/apt/sources.list ; \
sed -i "s/archive.ubuntu.com/${CONTAINER_PACKAGE_URL}/g" /etc/apt/sources.list ; \
fi && \
# 安装所需软件
apt-get update && apt-get install -yq sudo curl apt-transport-https gnupg tzdata && \
# 修改time zone
rm /etc/localtime && cp "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone && \
# 添加源
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list | tee /etc/apt/sources.list.d/mssql-server.list && \
apt-get update
apt-get update && \
# 安装 ( 分割,避免单个 layer 不至于太大 )
RUN apt-get install -y mssql-server
apt-get install -y mssql-server && \
# 去除 2G 内存限制
RUN chmod +x /tmp/unlimited-memory.py && \
chmod +x /tmp/unlimited-memory.py && \
python /tmp/unlimited-memory.py && \
chmod +x /opt/mssql/bin/sqlservr && \
# 清除数据
Expand All @@ -36,8 +44,6 @@ RUN chmod +x /tmp/unlimited-memory.py && \
rm -rf /var/lib/apt/lists && \
rm -rf /tmp/*

VOLUME /data /backup /log /dump

EXPOSE 1433

CMD /opt/mssql/bin/sqlservr
3 changes: 1 addition & 2 deletions unlimited-memory.py → builder/unlimited-memory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
os.rename("/opt/mssql/bin/sqlservr", "/opt/mssql/bin/sqlservr.old")
oldfile = open("/opt/mssql/bin/sqlservr.old", "rb").read()
oldfile = open("/opt/mssql/bin/sqlservr", "rb").read()
newfile = oldfile.replace("\x00\x94\x35\x77", "\x00\x80\x84\x1e")
open("/opt/mssql/bin/sqlservr", "wb").write(newfile)
exit()
15 changes: 13 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ networks:
services:
mssql:
build:
context: .
image: edwinhuish/mssql
context: ./builder
args:
CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL}
image: edwinhuish/mssql-server
container_name: mssql-server
ports:
- 1433:1433
volumes:
- ./workspace/data:/data
- ./workspace/backup:/backup
- ./workspace/log:/log
- ./workspace/dump:/dump
restart: always
environment:
- TZ=Asia/Shanghai
- MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>
- MSSQL_PID=Express
networks:
- default
9 changes: 9 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Container package fetch url
#
# Can be empty, followings or others:
# mirrors.163.com
# mirrors.aliyun.com
# mirrors.ustc.edu.cn
#
CONTAINER_PACKAGE_URL=mirrors.aliyun.com
2 changes: 2 additions & 0 deletions workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 71a6f2e

Please sign in to comment.