您好,登錄后才能下訂單哦!
URLOS開發者功能已上線有一段時間了,目前通過部分開發者的使用體驗來看,不得不說URLOS在服務器軟件開發效率方面確實有著得天獨厚的優勢,憑借docker容器技術與其良好的應用生態環境,URLOS必將迅速成為軟件開發者的新寵兒。
本篇內容以入門為主,通過制作一個簡單的靜態網站環境應用,讓新晉開發者能在短時間內對URLOS的開發流程有所認識。
URLOS基于docker容器技術,因此在應用開發過程中我們離不開docker的相關命令,對docker還不太了解的朋友,可以先大致了解一下docker的相關內容,本篇不做詳細討論。
URLOS應用開發的基本流程
本篇目標是制作nginx靜態網站環境,那么我們需要做的內容包括:運行一個基礎鏡像,在此鏡像基礎上安裝nginx,設置網站根目錄,打包并上傳新鏡像,通過URLOS添加新應用,發布并導出應用。
為什么選擇Alpine作為基礎鏡像?因為Alpine的文件體積小啊,基礎鏡像只有5.53MB,相比ubuntu鏡像的88.9MB要小十幾倍。
使用docker pull alpine
命令拉取alpine鏡像:
root@ubuntu:~# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
bdf0201b3a05: Pull complete
Digest: sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913
Status: Downloaded newer image for alpine:latest
root@ubuntu:~#
然后使用docker images
命令查看鏡像:
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
urlos/urlos latest 4810506f7202 12 hours ago 447MB
alpine latest cdf98d1859c1 2 weeks ago 5.53MB
root@ubuntu:~#
運行Alpine鏡像并進入容器內部:
root@ubuntu:~# docker run -it alpine sh
/ #
更換更新源:
/ # vi /etc/apk/repositories
將其中內容換成阿里云的源
/ # cat /etc/apk/repositories
https://mirrors.aliyun.com/alpine/v3.6/main/
https://mirrors.aliyun.com/alpine/v3.6/community/
/ #
使用apk update
執行更新:
/ # apk update
fetch https://mirrors.aliyun.com/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch https://mirrors.aliyun.com/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.5-25-g77eea063d8 [https://mirrors.aliyun.com/alpine/v3.6/main/]
v3.6.5-18-gfdfe1f6192 [https://mirrors.aliyun.com/alpine/v3.6/community/]
OK: 8453 distinct packages available
/ #
使用apk add nginx
安裝nginx:
/ # apk add nginx
(1/4) Installing libressl2.5-libcrypto (2.5.5-r2)
(2/4) Installing pcre (8.41-r0)
(3/4) Installing libressl2.5-libssl (2.5.5-r2)
(4/4) Installing nginx (1.12.2-r2)
Executing nginx-1.12.2-r2.pre-install
Executing busybox-1.29.3-r10.trigger
OK: 9 MiB in 18 packages
/ #
保護pid:
/ # cd /run/
/run # mkdir nginx
添加網站根目錄:
/ # mkdir -p /data/www/
修改nginx配置文件:
/data/www # vi /etc/nginx/conf.d/default.conf
/data/www # cat /etc/nginx/conf.d/default.conf
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
index index.html;
root /data/www;
}
# You may need this to prevent return 404 recursion.
location = /404.html {
internal;
}
}
/data/www #
測試nginx:
/data/www # nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
OK,nginx配置完成!
使用exit
退出容器,準備打包鏡像。
/data/www # exit
root@ubuntu:~#
使用命令docker ps -a
查看所有容器:
root@ubuntu:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a5249fa1d7ec alpine "sh" 35 minutes ago Exited (0) 2 minutes ago youthful_heisenberg
1502c4163c2c urlos/urlos:latest "sh /entrypoint.sh" 2 hours ago Up 2 hours 0.0.0.0:9001->9001/tcp, 0.0.0.0:9966->9966/tcp, 0.0.0.0:9968->9968/tcp urlos
root@ubuntu:~#
使用docker commit
命令打包鏡像,然后使用docker images
命令查看鏡像:
root@ubuntu:~# docker commit a5249fa1d7ec yeqing112/alpine-nginx:0.0.1
sha256:4730bd89ee3e9408f0ba29c5c80ad0a13600b82de565bbc49f3d4ec8585902c4
root@ubuntu:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
yeqing112/alpine-nginx 0.0.1 4730bd89ee3e 13 seconds ago 10MB
urlos/urlos latest 4810506f7202 13 hours ago 447MB
alpine latest cdf98d1859c1 2 weeks ago 5.53MB
root@ubuntu:~#
OK,我們成功制作了一個名稱為yeqing112/alpine-nginx的新鏡像。
首先使用命令docker login
進行登錄,如果沒有docker賬號,請到docker官網注冊:
root@ubuntu:~# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
root@ubuntu:~#
使用docker push
命令上傳鏡像:
root@ubuntu:~# docker push yeqing112/alpine-nginx:0.0.1
The push refers to repository [docker.io/yeqing112/alpine-nginx]
bbe56e36ea7a: Pushed
a464c54f93a9: Mounted from library/alpine
0.0.1: digest: sha256:94c5f0c38a3de543cde52791b3daff3fdc8001e99bf58bb08230b2cab3e062a3 size: 739
root@ubuntu:~#
打開docker鏡像倉庫可以看到我們上傳的鏡像了
鏡像上傳成功后,訪問http://主機ip:9968
登錄URLOS主控,我們將在這里面進行應用的添加(沒有安裝URLOS的,百度搜索URLOS,到官網查看安裝方法)。
登錄urlos主控后,我們先檢查URLOS版本和模式是否正確,制作應用我們需要使用URLOS付費版本,這里我使用了URLOS標準版,并且需要將模式改為DEV(開發模式),具體修改方法到URLOS官網查看。
我在這一步要偷偷懶,直接復制一個已有應用,然后稍作修改。那我們選擇復制什么應用呢?其實官方有一個靜態網站的應用,直接復制過來修改即可。在應用管理列表中搜索nginx
關鍵詞,找到系統自帶的靜態網站應用:
點擊更多
按鈕,在彈出菜單中選擇復制應用
:
以下截圖中標紅的內容是必須修改的,其他內容的修改視個人情況而定。
基本信息:
這里我們就修改應用名稱和鏡像即可。
在當前項目中,其他選項我們不需要去修改,因為那些內容跟我們的需求是一樣的。
點擊提交
按鈕,OK,我們的應用制作完成了!啊?這么快?沒錯!就是這么快。
然后我們通過這個新應用快速的部署一個網站試試,點擊更多
,彈出菜單中選擇創建服務
部署完成瀏覽器打開網站,靜態網站成功運行!
我們還可以將這個靜態網站應用導出來,轉給其他用戶導入使用:
導出的是文本文件,體積非常小:
導入應用時,只需將文本中的內容復制黏貼即可:
以下是這個應用導出的文本內容,僅供大家測試:
{
"appName": "my-nginx-website",
"appVersion": "0.1.0",
"appPrivileged": 0,
"imageUrl": "yeqing112\/alpine-nginx:0.0.1",
"exportTime": "2019-04-27 14:01:00",
"exportData": "5Rv8VFcUKLyJEH5nE6rVfoGNG1WKhUI_38OBEL_--7OxDFjRCeo4yB3RLJYz7YCEbOHD4INhvnWNXZIb6Tpj6FPV0rC4GrGvVjgfHTMYsklOTXqsATJgHfZmyny6y-94dgYpdQ33pb1eG0tbASNEi-NWZURzRhxbQefT3ctMIlHNR2fejocppWjAKR-o6h7dyGVEdCZaYmUaf59Un_i-y8yuaPKPWhWY3IolA1dSoZLMv0iKT4e-UubBhZC-hOz1YQT3KeNYgdjGGJKLd0rTc950X6hkwmo0jh8MuGg_RCNtWoe0DFxKjMz_TXbKaBmPbzutco3Xgr2FHGCeI60KAMfdA7EWMV0pIJbRem2_prbctwHfRc2CIq42Uc9CGf4dtrYL0cTbQVztFJ7ZKc4v_hHxJmxZCQD9ZMr_TYnYkvQVH8fG_pgy4Qknx7Oh9FBOoyBxxSeif1PkceQZuHRcyKxvwtthLIeAlskZOF7zJYrfAtiYf_kkqn5lBkGGbpDPG9-_wMtatMkeuypSJNDQOC-mJiP_KUT1a_YzuKwgbbv4185RPiW2XiAH_xFW_TF_m48rrmhLXTJ4MkVC3Ey2FoR4Tnf6JBt5kdMLov3OODXJP7WCl63H_0JYGgirqmaECyV0LKAf15RPCGu7DvXEL-YN8y21MQsFGwQ6vjA5EGGzIdaSntn-D8Y9fztLW2gHaSJpJEguaW3I7JysdQkiUbFLSDXSSoEvZKA6WijkccMV7qVlBWRXMmOFNdFw9qV5LgZmqGUvXK_NtFKk3XU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74kkkpG6kUucGXmlZXcFCplP4bcIKmhYdXtPwqT_gbhUeLvzaWo90qgmhJ_SkzvbkVboZdSCdNh-68ib9o5Wf8FL3BdycCcKLRnKbLF8kFL6RDdJPupojem19kll_Wwb0r31DhgeF9xMVXd2hvtck_EW_c45sbrk_L097-6QBmW4ZVgLCn4_xM7G3sUD2T8Cu--g6xRMP3x2jc4tRfFErE55buKV2y_o-_J8NSuuGojDdLo6KGJ1bbg7Sy92wDYEKzTeDs5u3cxoLd9CRHZ-_FvSGvYRyaxgMv1jo-MFpStswW5kbIy4IxPOkrMneADLd03AWyC_EBTpWCE1_mjPyfbvb8CAiBxcNlEdMukttap8EY22ZX7VytjdWxFVQRN7rrj9bP-bKo_U712c8KGgkuQjRMnQHuVB03-RAjCPlpVu39GbK28YjNEXRt2rdxj0LgGSviZbfgi10nKU9QCN5YdeCTnzidBWLfv_vSbDbKJoiSKg2Pg4gDDc-E85EJZZujRnxc="
}
歡迎廣大開發者一同交流
URLOS官網:https://www.urlos.com/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。